Overriding Existing Methods : Overriding Methods « Class « Ruby






Overriding Existing Methods


class String
  def length
    20
  end
end
puts "This is a test".length
puts "a".length
puts "A really long line of text".length

 








Related examples in the same category

1.override your own methods
2.Overriding Methods Demo
3.Override method from parent