Assignment question

Kaye Ng wrote:

#Run this code

x=[2,6,5,9]
y = x

x and y are pointing to the same array

x=[1,2,3,4]

Now x is pointing to a different array (look at x.object_id and
y.object_id)

x=[2,6,5,9]
y = x

x and y are pointing to the same array

x.pop

x and y are still pointing to the same array. You modified this array by
popping an element off it.

So you need to remember:
* Every value in Ruby is an object *reference*
* Most objects in Ruby are mutable, i.e. their internal state can
change.

a = "hello"

=> "hello"

b = a

=> "hello"

a.upcase!

=> "HELLO"

a

=> "HELLO"

b

=> "HELLO"

ยทยทยท

--
Posted via http://www.ruby-forum.com/\.