lua-users home
lua-l archive

RE: attempt to perform arithmetic on field '_income' (a table value)

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


 Can someone kindly explain the reason why I see this error ?
 tax.init = function (pIncome, pRate)
 tax._income = pIncome
 tax._rate = pRate
 end
 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
tax._rate
is assigned what you think is pIncome and what you think is pRate is
thrown
away. 
Try changing the call to tax.init(12200, 12) or change the function
definition
to tax.init = function (self, pIncome, pRate).
Chris Berardi

AltStyle によって変換されたページ (->オリジナル) /