Re: Subclassing Struct.new
by Chiaro Scuro other posts by this author
Feb 28 2006 5:14AM messages near this date
Re: Subclassing Struct.new
|
Re: Subclassing Struct.new
On 2/28/06, Ross Bamford <rossrt@[...].uk> wrote:
> 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".
>
> Using self.n = 1 forces Ruby to treat the assignment as involving the
> method 'n' on 'self'.
>
> I don't think it's a bug, but I know it's tripped people (including me)
> up before. From the implementation point of view it's probably the
> lesser of two evils, though.
It's really unrubesque and tricky. What would be the consequences of
handling it as you would normally expect? What would the side effects
be?
--
-- Chiaroscuro --
Liquid Development Blog: http://feeds.feedburner.com/blogspot/liquiddevelopment
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
|