In julia functions : passed by reference or value?
<p>In julia how do we know if a type is manipulated by value or by reference?</p>

<p>In java for example (at least for the sdk): </p>

<ul>
<li><p>the basic types (those that have names starting with lower case letters, like "int") are manipulated by value</p></li>
<li><p>Objects (those that have names starting with capital letters, like "HashMap") and arrays are manipulated by reference</p></li>
</ul>

<p>It is therefore easy to know what happens to a type modified inside a function.</p>

<p>I am pretty sure my question is a duplicate but I can't find the dup...</p>

<p><strong>EDIT</strong></p>

<p>This code :</p>

<pre><code>function modifyArray(a::Array{ASCIIString,1})
    push!(a, "chocolate")
end

function modifyInt(i::Int)
    i += 7
end

myarray = ["alice", "bob"]
modifyArray(myarray)
@show myarray

myint = 1
modifyInt(myint)
@show myint
</code></pre>

<p>returns :</p>

<pre><code>myarray = ASCIIString["alice","bob", "chocolate"]
myint = 1
</code></pre>

<p>which was a bit confusing to me, and the reason why I submitted this question. The comment of @StefanKarpinski clarified the issue.</p>

<p>My confusion came from the fact i considred += as an operator , a method like push! which is modifying the object itself . but it is not.</p>

<p><code>i += 7</code> should be seen as <code>i = i + 7</code> ( a binding to a different object ). Indeed this behavior will be the same for <code>modifyArray</code> if I use for example <code>a = ["chocolate"]</code>.</p>