Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Why making a change in a copy of a variable changes the original variable?

$
0
0

I am so confused now. Can you explain this to me:

aa = [1,2,3]
bb = aa
bb[1,1] = 66

Output:

bb = 3-element Array{Int64,1}:
 66
  2
  3

aa = 3-element Array{Int64,1}:
 66
  2
  3

I am only making a change in bb, why aa is changing as well?

17 posts - 9 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles