local function newObject (value)
return function (action, v)
if action == "get" then return value
elseif action == "set" then value = v
else error("invalid action")
end
end
end
local d = newObject(1)
print(d("get"))
d("set",2)
print(d("get"))
1
2
lua single-method
最新推荐文章于 2022-11-11 21:31:07 发布