RosettaCodeData/Task/Call-an-object-method/Lua/call-an-object-method-3.lua
Ingy döt Net 6f050a029e update
2013-06-05 21:47:54 +00:00

16 lines
328 B
Lua

local count = 0
local box = { }
local boxmt = { __index = box }
function box:tellSecret ()
return self.secret
end
local M = { }
function M.new ()
count = count + 1
return setmetatable({ secret = count, contents = count % 2 == 0 and "rabbit" or "rock" }, boxmt)
end
function M.count ()
return count
end
return M