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/.