[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: attempt to perform arithmetic on field '_income' (a table value)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 18 Sep 2013 14:35:34 +0200
2013/9/18 Chris Berardi <firstname.lastname@example.org>:
> Can someone kindly explain the reason why I see this error ?
> tax.init = function (pIncome, pRate)
> tax._income = pIncome
> tax._rate = pRate
> tax:init(12200, 12)
> The way Lua handles OO, the call to tax:init(12200, 12) is syntactic
> sugar for
> tax.init(tax, 12200, 12). Therefore, tax._income is assigned tax and
> is assigned what you think is pIncome and what you think is pRate is
> Try changing the call to tax.init(12200, 12) or change the function
> to tax.init = function (self, pIncome, pRate).
And change all the tax.xxx statements to self.xxx statements.