Re: Subclassing Struct.new
by Minkoo Seo other posts by this author
Feb 28 2006 4:53AM messages near this date
Re: Subclassing Struct.new
|
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
Thread:
Minkoo Seo
Chiaro Scuro
Minkoo Seo
Yukihiro Matsumoto
Mark Wilden
Markus Werner
Chiaro Scuro
Minkoo Seo
Minkoo Seo
Hal Fulton
mental
Ross Bamford
mental
Ross Bamford
Chiaro Scuro
Ross Bamford
Chiaro Scuro
Minkoo Seo
Chiaro Scuro
mental
Chiaro Scuro
mental
Yukihiro Matsumoto
Caleb Clausen
Yukihiro Matsumoto
Caleb Clausen
MenTaLguY
Yukihiro Matsumoto
gwtmp01
Chiaro Scuro
mental
Chiaro Scuro
mental
Logan Capaldo
Pit Capitain
|