Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/Call-an-object-method/Lua/call-an-object-method-3.lua
Normal file
16
Task/Call-an-object-method/Lua/call-an-object-method-3.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue