From: "Gerardo Santana Gómez Garrido" Date: 2005-12-29T14:04:03+09:00 Subject: Re: Locking classes? 2005/12/28, Max Eskin : > Hi, > I am just starting to use Ruby. I'm wondering, once a class has been > declared, is there any way to lock it to prevent further methods from > being defined? In other words is there a way to make Ruby act like a > static language for some classes? Use Module#freeze class A def self.f(a) a + 1 end end puts A.f(1) # => 2 A.freeze #=> runtime error: "can't modify frozen object (TypeError)" class A def self.f(a) a - 1 end end puts A.f(1) -- Gerardo Santana "Between individuals, as between nations, respect for the rights of others is peace" - Don Benito Ju�rez http://santanatechnotes.blogspot.com/