(no title)
qquark | 6 years ago
OTOH, if your problem is slightly different, I find the syntax to add methods to any class very practical and powerful, with of course the caveat that you can produce a maintainability nightmare if overused:
irb(main):001:0> a = 1
=> 1
irb(main):002:0> class Integer
irb(main):003:1> def hello
irb(main):004:2> puts "world"
irb(main):005:2> end
irb(main):006:1> end
=> :hello
irb(main):007:0> a.hello
world
=> nil
No comments yet.