From: Minkoo Seo Date: 2006-02-28T21:53:36+09:00 Subject: Re: Subclassing Struct.new Ross Bamford wrote: > Normally, n + 1 would end up calling your method because Ruby would have > to figure out whether it's a method or variable, but because in this > case Ruby has seen a bare assignment to 'n' by that point, it remembers > that and assumes 'n' is a local variable. > > This local variable isn't yet initialized (the n + 1 would be it's > initializer), so n + 1 ends up being nil + 1, or (effectively) nil.+(1), > hence the "undefined method '+' for nil:NilClass". Sigh. This reminds me of the rule that I have to use "this->method_name( )" when I want call a method of T, parent class, which is passed as template parameter. Anyway, it's not a perfect world... Best, Minkoo Seo