Ruby sometimes feels like the grumpy parent that gives in to a child’s demands, after they’ve thrown a tantrum. In this case the child represents us, programmers.
Though if you look at it more carefully, you’ll find that, in fact, Ruby is a language that respects the programmer. That explains why there are so many things you can do, which you can’t do in many other languages.
While not the most fascinating tidbit, I found the following quite interesting:
class Bonkers
def go_wild
def wilder
def i_said_wilder!
'okay'
end
end
end
end
Interestingly, all methods above are defined for the Bonkers
class. So if you instantiate an object of this class, you’ll have all three methods at your disposal to call.
[1] pry(main)> class Bonkers def go_wild def wilder def i_said_wilder! 'okay' end end end => :go_wild [2] pry(main)> o = Bonkers.new => #<Bonkers:0x000000014c2c3e20> [3] pry(main)> o.go_wild => :wilder [4] pry(main)> o.wilder => :i_said_wilder! [5] pry(main)> o.i_said_wilder! => "okay"