Freeze a class : freeze « Class « Ruby






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

 








Related examples in the same category

1.Extends a frozen class