Lua 单例类

function SingleTon:new()

  local store = nil

  return function(self)

    if store then return store end
    local o ={}
    setmetatable(o,self)
    self.__index = self
    
    store = o
    return  o
  end

end

SingleTon.instance = SingleTon:new()

 

posted @ 2016-09-26 16:21  Guoliangjun  阅读(668)  评论(0编辑  收藏  举报