Hi folks
I'm using ruby 1.8.2 as comes with Mandriva 2005LE and get the following behaviour with arrays which doesn't seem logical to me.
In irb I do
irb(main):058:0* a=[1,2,3,4,5]
=> [1, 2, 3, 4, 5]
straight forward enough
irb(main):059:0> b=a
=> [1, 2, 3, 4, 5]
irb(main):060:0> c=a
=> [1, 2, 3, 4, 5]
I've set 2 more variables to equal 'a'
irb(main):061:0> b[3] = 'w'
=> "w"
I believe this changes index 3 in'b' to now be equal to 'w'
do
irb(main):062:0> b
=> [1, 2, 3, "w", 5]
that's exactly as I expected, BUT
irb(main):063:0> a
=> [1, 2, 3, "w", 5]
irb(main):064:0> c
=> [1, 2, 3, "w", 5]
so what's the logic behind 'a' & 'c' changing when I change 'b'.
Is this a bug? and if not what's the reasoning behind this behaviour please.
Best Rgds from confused of Heathfield
Nigel
···
__________________________________________________________________________
Disclaimer
Any opinions expressed in this email are not necessarily those of my wife