From: Florian Frank Date: 2003-08-27T00:10:13+09:00 Subject: Re: Freezing OpenStruct On 2003-08-26 21:39:34 +0900, Gavin Sinclair wrote: > The irb session below demonstrates that OpenStruct objects (part of > the standard library) allow modification after a #freeze. Is this > desirable? It don't think so. A quick fix would be that: Index: ostruct.rb =================================================================== RCS file: /src/ruby/lib/ostruct.rb,v retrieving revision 1.6 diff -u -p -r1.6 ostruct.rb --- ostruct.rb 18 Nov 2002 20:09:46 -0000 1.6 +++ ostruct.rb 26 Aug 2003 15:05:08 -0000 @@ -38,6 +38,11 @@ class OpenStruct @table.delete name.to_sym end + def freeze + super + @table.freeze + end + def inspect str = "<#{self.class}" for k,v in @table -- Simplicity is prerequisite for reliability. [Handwritten annotation] -- Edsger Dijkstra, How do we tell truths that might hurt?