Meino Christian Cramer wrote: > Ooopps.....the newbie's nightmare becomes reality. > > I tend to say, that this side effect is not what I would have > exspected... > > My innocent (newbie) knowledge may be the reason for it... > > Well, I think the big reason for the above problem in this case is that Ruby Strings aren't immutable like they are in Java. You could have the same problem in C++: class Foo { string var; public: string & getVar(); void setVar(const string & s); }; ... Foo foo; foo.setVar("blarg"); ... string s = foo.getVar(); s[0] = 'f'; cout << foo.getVar(); // prints "flarg" The difference in C++ is that reference types must be explicitly declared. You'd have the same problem in Java with mutable objects, though. class IntWrapper { private int value; public IntWrapper(int v) { value = v; } public void setValue(int i) {value = i; } public int getValue() { return value; } } class Example { private IntWrapper integer; public Example() { integer = new IntWrapper(33); } public IntWrapper getInteger() { return integer; } public String toString() { return Integer.toString(integer.getValue()); } } Example e = new Example(); ... IntWrapper mutable = e.getInteger(); mutable.setValue(55); System.out.println(e); // prints 55 instead of 33 So this problem is not unique to Ruby. Note, all this code is off the top of my head, so it may contain syntax errors. :) Cheers. - Dan