I am reading the chapter 16.4 of Programming in Lua and I can’t get one thing in the last example:
function newAccount (initialBalance)
local self = {
balance = initialBalance,
LIM = 10000.00,
}
local extra = function ()
if self.balance > self.LIM then
return self.balance*0.10
else
return 0
end
end
local getBalance = function ()
return self.balance + self.extra() -- this line is the problematic one
end
...
HOW the “extra” function has become a “self.extra” one?! I don’t see anything which makes it attached to the separate “self” table!
This has been corrected in the second edition of the book to