[LRUG] Unexpected behaviour of << operator

Matthew Willson matthew at playlouder.com
Wed Aug 18 08:41:23 PDT 2010


> Actually, giving it more thought, of course that makes sense, and it is indeed what I would expect - too much treating a string like a string and not an object!

A lot of languages (javascript, for one) deliberately implement strings as immutable data structures, to avoid exactly this kind of bug. I wouldn't feel too bad about it!

String#freeze might be worth a try if you find this kind of these kinds of things cropping up too often.

-Matt


More information about the Chat mailing list