Variables when passed to functions

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, 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, 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?

Yes, that seems ok to say.

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.

7 Likes