From: "Jesús Gabriel y Galán" Date: 2010-06-16T20:31:13+09:00 Subject: Re: Getting rid of self On Wed, Jun 16, 2010 at 1:28 PM, Jason Roelofs wrote: > 2010/6/16 Jesús Gabriel y Galán > >> On Wed, Jun 16, 2010 at 11:37 AM, Andrea Dallera >> wrote: >> > Have you tried it like this? >> > >> > >> > --- >> > >> > def initialize(attributes = nil) >> > >> >  super attributes >> > >> >  step                = 0 >> > >> >  national_debt       = 0 >> > >> >  sum_of_income       = 0 >> > >> >  sum_of_taxes        = 0 >> > >> >  sum_of_happiness    = 0 >> > >> >  sum_of_investments  = 0 >> > >> > end >> > >> > --- >> > >> > >> > 'self' is the default receiver inside a method >> >> That won't work, because the parser sees this as local variable >> assignments, and not method calls. >> I don't know an easy way to remove that. >> > > If they're ivars (attr_accessible), then just use the ivar itself. If they > are methods on the class, then you'll need the self for there reason you > mentioned: > > def initialize(attributes = nil) > >  super  # If exact signature, don't need arguments > >  @step                = 0 > >  @national_debt       = 0 > >  @sum_of_income       = 0 > >  @sum_of_taxes        = 0 > >  @sum_of_happiness    = 0 > >  @sum_of_investments  = 0 > end Only if you assume that the setter methods only set the ivar. If there's extra logic in the setter method, to call it you need the self. Jesus.