Martin Chandler
10/5/2008 10:16:00 AM
Hi,
Please excuse the newbie question, but I am confused by something I see with
sub!() (this seems to be true with other "!" operations as well):
irb(main):001:0> string1 = "hello"
=> "hello"
irb(main):002:0> string2 = string1
=> "hello"
irb(main):003:0> string2.sub!(/e/,"a")
=> "hallo"
irb(main):004:0> string2
=> "hallo"
irb(main):005:0> string1
=> "hallo"
irb(main):006:0>
Why is string1 also changed when sub!() is being performed on string2 ?
Shouldn't sub!() only be acting on the string it is being called on?
Thanks,
Martin