[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How to change class member data reference?
- From: albert_200200 <albert_200200@...>
- Date: Thu, 11 Sep 2014 16:08:43 +0800
First I use the following code to define a lua class:
clsSMSSend = {}
function clsSMSSend:new()
local o = {}
setmetatable(o, self)
self.__index = self
o.MobileNo = "oldmobile"
o.tbl_body = {
[1] = o.MobileNo,
}
return o
end
The problem is as below:
obj = clsSMSSend:new()
obj.MobileNo = "newmobile"
for k, v in ipairs(obj.tbl_body) do
print(k, v) --but here still print "oldmobile" not "newmobile"
end
If I want the code to print "newmobile", how can I correct it? Thanks.