# Variables when passed to functions

**URL:** <https://discourse.julialang.org/t/variables-when-passed-to-functions/57476>\
**Category:** General Usage\
**Created:** [March 18, 2021, 1:32pm UTC](https://discourse.julialang.org/t/variables-when-passed-to-functions/57476 "2021-03-18T13:32:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon60034542](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Post date:** [March 18, 2021, 1:32pm UTC](https://discourse.julialang.org/t/variables-when-passed-to-functions/57476/1 "2021-03-18T13:32:34Z")

</div>

```julia
function add!(character_storage ::Dict{String,Int32}, acquired :: Pair{String,Int32})
	push!(character_storage,acquired)
end

items = Dict{String,Int32}()
orb_of_health :: Pair = ("Orb" => 10)

```

According to the [documentation](https://docs.julialang.org/en/v1/manual/variables/),` items` is bound to the `Dict{String,Int32}()`.

1. When the dictionary gets passed to `add!()`, is it correct to say that `character_storage` is now bound to the dictionary?
2. Because Julia uses [pass by sharing](https://docs.julialang.org/en/v1/manual/functions/#Argument-Passing-Behavior), and we shared a mutable dictionary, any changes made to `character_storage` are also made to `items`, because the dictionary now has two names bound to it, correct?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [March 18, 2021, 1:43pm UTC](https://discourse.julialang.org/t/variables-when-passed-to-functions/57476/2 "2021-03-18T13:43:27Z")

</div>

> [@anon60034542](#):
>
> When the dictionary gets passed to `add!()` , is it correct to say that `character_storage` is now bound to the dictionary?

Yes, that seems ok to say.

> [@anon60034542](#):
>
> any changes made to `character_storage` are also made to `items` , because the dictionary now has two names bound to it, correct?

Kind of. The change is not really made to either `character_storage` not `items`. It is made to the dictionary itself. But since both of these variables are bound (or point) to **the same** dictionary, accessing the dictionary through those variables will both obtain the same (modified) dictionary.
