The function(s) defined within a function works fine with any hierarchy only within the main object but gives NoMethodError inside a class.

Lets exemplify it!

Here are the example of both main object and inside a class…

Its an unexpected behavior in the main object. I don’t know whether its a bug or the feature. But as Matz says it will be removed in the future version of ruby, might be in 2.0

Share this: