Created
February 11, 2014 11:57
-
-
Save wujiyu115/8933564 to your computer and use it in GitHub Desktop.
lua:instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello = {} | |
function Hello:new() --private method. | |
local store = nil | |
return function(self) | |
if store then return store end | |
print"create." --for test. | |
local o = {} | |
setmetatable(o, self) | |
self.__index = self | |
store = o | |
return store | |
end | |
end | |
Hello.instance = Hello:new() --implement single instance object. | |
--test following | |
local hello = Hello:instance() --> create. | |
local hellohello = Hello:instance() --no output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment