From: Dave Anderson Date: 2009-11-01T06:50:13+09:00 Subject: Re: In-place parameter modification Rick Denatale wrote: ... > Objects are instances of classes, and typically have state, in some > cases like Fixnums the only state is really the object's identity, and > such objects are immutable, if two such objects have different state, > then they MUST be different objects. There is only one 1 object and > one 5 object. Symbols are similar in that there is only one instance > of symbol with a particular value. Thanks for the fascinating and valuable insights, Rick. I didn't realize what a can of worms I was opening here. And it's nice to know that someone here remembers Fortran II, although that might make you a good candidate for a Men-In-Black neurolizer. ;-) As an old hand at C++, this variable/value/type stuff is a very worthwhile lesson. One practical thing I can draw out of this is the difference between these two functions: def X_1( str ) str[0] = 'X' end def X_2( str ) str = 'X' + str[ 1..-1 ] end The X_1 function alters the passed-in object in place, while the X_2 function modifies a local copy. I don't recall reading this in the literature anywhere. -- Posted via http://www.ruby-forum.com/.