s1 = "string" s2 = s1 s2 << "a" s1.should == s2
string s1 = "string"; string s2 = s1; s2.Insert( 0, "a" ); Assert.NotEqual( s1, s2 );
Strings in C# are immutable. So trying to change a string actually creates a new string. So updating s2 does not update s1.
Strings in Ruby are mutable. So strings in Ruby act like pointers and s1 is updated when you update s2.
To be more clear, here are some more examples of how Ruby behaves:
s1 = "string" s2 = s1 s2 += "a" s2.should_not == s1
s1 = "string" s2 = s1 s2.gsub!('s','z') s2.should == s1