Extends a frozen class : freeze « Class « Ruby






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

 








Related examples in the same category

1.Freeze a class