Long time no read, I know. Well, I have been away.
Anyways, while I am not back yet, I stumbled across something that made me wonder: consider this:
class X def self.a def self.b; "b"; end b() end def self.x b end end
The ruby feature which allows you to define a function within another function is relatively new to me. Since I found out about it I used it to split a function into several parts but not to publish the parts in any namespace accessible from the outside, i.e. the parts should be accessible only from within the method.
Turns out that I was wrong. Apparently a “not-really inner function” is defined at whatever outer level exists (hence the need for the “self” part in “def self.b; …; end” in the example above). The method “b” is defined on the X class object, i.e. as if was written
class X def self.b; "b"; end def self.a; b(); end end
Seems I will stop using that idiom.