On Mon, Aug 27, 2012 at 10:58 AM, Ryan Davis <[email protected]> wrote: > > On Aug 27, 2012, at 01:47 , Robert Klemme <[email protected]> wrote: > >> On Sat, Aug 25, 2012 at 11:36 PM, Marc Heiler <[email protected]> wrote: >>> I think he basically wants to have a class that can never ever again be >>> changed. >>> >>> As far as I know, this is not possible in ruby. >> >> In what ways can you still change a frozen class? > > class X; freeze; end > X = X.dup
The constant reassignment will prompt a warning. > class X; def y; end; end # works fine You are not actually modifying the original class X. Instead you create a copy and modify that. > The people looking for these assurances have to be educated that it just > isn't something that is worthwhile trying here. Well, at least particular measures help others recognize that it is a bad idea what they are trying (i.e. doing the dup reassign trick you present above can be done but will prompt a warning). Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
