单例代码

2015-12-14 0 577
单例代码
Singleton = {};
 
local _instance;
 
function Singleton.getInstance()
    if not _instance then
        _instance = Singleton;
    end
 
    --'any new methods would be added to the _instance object like this'
    _instance.getType = function()
        return 'singleton';
    end
 
    return _instance
end
 
function Singleton:new()
    print('Singleton cannot be instantiated - use getInstance() instead');
end

遇见资源网 lua 单例代码 http://www.ox520.com/14729.html

上一篇:

已经没有上一篇了!

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务