- Point ID definition and point ID call: a bit similar to the access method of data index
girl = {money = 200}
function girl.goToMarket(girl ,someMoney)
girl.money = girl.money --someMoney
end
girl.goToMarket(girl ,100)
print(girl.money)
- Parameter self points to the caller itself (similar to this in c++ points to the current class)
girl = {money = 200}
--This function is declared as a local type and will report an error
function girl.goToMarket (self, someMoney)
self.money = self.money - someMoney
end
girl.goToMarket(girl, 100)
print(girl.money)
- Colon definition and colon call:
girl = {money = 200}
function girl: goToMarket (someMoney)
self.money = self.money - someMoney
end
girl: goToMarket (100)
print (girl.money)
Reference materials: