Hi,

Your explanation makes sense, but, coming from MATLAB, I must admit I'm not 
familiar with the numerical values of a particular array (in this case 
astore) changing when another variable (in this case a) is changed. I hope 
you don't mind a few follow-up questions :) 

 - Is this behaviour explained somewhere in the Julia docs so people can 
clearly know which operations create a new array (as in my first example) 
and which operations modify the values of an existing array (as in the 
second example)?
 - Is there a 'Julian' way of getting the result of my first example while 
changing individual elements of 'a' as I've done in the second example? In 
each loop I want to change particular values a[i], and then statically 
store the numerical value of a in astore, before commencing to the next 
iteration - is there a way to easily do this in Julia? 

Thanks

On Friday, 11 December 2015 17:07:42 UTC+11, [email protected] wrote:
>
> Looks right to me.  
>
> In the first version `a = a + 1` makes `a` refer to a *new* array with 
> values one greater and `push!(astore,a)` stores the reference to the new 
> array in `astore`.
>
> In the second version you modify the values of the array already referred 
> to by `a` and then push a reference to that array, but every time you push 
> it is a reference to the same array, so in the end all you have is lots of 
> references to the same array.
>

Reply via email to