Ruby/Class/freeze
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 17:55, 13 сентября 2010
Extends a frozen class
class MyClass def my_method puts "This is the only method allowed in MyClass." end MyClass.freeze end class MySubclass < MyClass def my_method "This is only one of the methods available in MySubclass." end def my_other_method "This is the other one." end end MySubclass.new.my_method
Freeze a class
class MyClass def my_method puts "This is the only method allowed in MyClass." end MyClass.freeze end class MyClass def my_method puts "I like this implementation of my_method better." end end