From: Timothy Hunter Date: 2006-02-13T06:38:25+09:00 Subject: Re: Equivalent of const modifier eastcoastcoder@gmail.com wrote: > Very often, I'd like to ensure (and document) that a method will not > change any of its parameters: > > # This looks at, but doesn't modify, a and b > def mymethod(a, b) > end > > In C++ I can do this with the const modifier. > > Is there anyway to do this in Ruby? > > I'd call freeze, except that would freeze the original a as well. > I'd call dup/clone and then freeze, but those aren't deep copies, from > what I understand. > > So, I guess my question boils down to: > Is there a way to make a frozen, full (ie deep) copy of an object? > You can make a deep copy and then freeze the copy. http://www.rubygarden.org/ruby?Make_A_Deep_Copy_Of_An_Object