Messin with Method Missin
| rubyRuh roh, check this snippet inspired by Metaprogramming Ruby:
Nice juicy stack level too deep (SystemStackError)
. What’s happenin?
Since number
is defined within the block, it is out of scope once the
last puts
statement tries to reference it. Ruby interprets number
to
then be a method call on self
, and since DungeonDice
does not have a
method called number
, it calls method_missing
! Dice ROLL!