There has probably been some discussion about this problem so sorry if I
am repeating but it is so crucial that should be mention every once in a
while.

This simple example:

a=['0']
1.upto(2) do
  b = a.clone
  c = a.clone
  b[0] << '1'
  c[0] += '2'
end
p a

yields ['011'] in ruby 1.8.6 and 1.9.3. I think that it should be ['0']

I understand the difference between << an += operator but shouldn't
clone method make a duplicate of object a, without any link to original
object.

Or am I missing something.

by
TheR

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