--000e0cd564505ff00c0489240487
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

2010/6/16 Jes Gabriel y Gal <jgabrielygalan / gmail.com>

> On Wed, Jun 16, 2010 at 11:37 AM, Andrea Dallera
> <andrea / andreadallera.com> 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

Oh, and you never need to return anything from #initialize.

Jason

--000e0cd564505ff00c0489240487--