From: Marcio Braga Date: 2008-08-17T23:22:06+09:00 Subject: Re: Matrix: Need help to understand this behavior Just to complement, as a contrast, the code below works as expected, or in other words, the content of matrix "a" is not changed when you change the content of matrix "b". b=[] a=[1] b[0]=a[0] # explicitly set a single element and not the entire matrix b[0]=2*b[0] p a Marcio Marcio Braga wrote: > a=[1] > b=a # make matrix "b" equal matrix "a", but expected 2 > separated matrices > b[0]=2*b[0] # I want to change matrix "b" (and not matrix "a") > p a # print matrix "a" and see the "issue" > > The expected value in the matrix "a" should be 1, but instead it is 2. > > Why ? > > Thank you. > Marcio -- Posted via http://www.ruby-forum.com/.