From: Mike Gold Date: 2009-02-09T05:23:19+09:00 Subject: Re: best way to protect class instance variables Jes炭s Gabriel y Gal叩n wrote: > > This could save you from accidental changes, but somebody could always > do this and trash your frozen array: > > irb(main):017:0> class Blah > irb(main):018:1> @blah = %w{nothing is really safe} > irb(main):019:1> end Data from a closure cannot be overwritten in this way, and could qualify as being "really safe". class MyClass class << self blah = [0,1] define_method(:blah) { blah } end end p MyClass.blah #=> [0, 1] -- Posted via http://www.ruby-forum.com/.