lua-users home
lua-l archive

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


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.