精灵的私人建设者

时间:2016-01-13 07:35:18

标签: constructor private genie

这一小段Vala代码,我是从rosettacode

中读取的
$('#example')

瓦拉:

public class Singleton : Object {
    static Singleton? instance;

    Singleton() { }  // Private constructor

    public static Singleton get_instance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }
}

将输出错误

  

错误:访问私有成员`Singleton.new'被拒绝

如何在Genie中做到这一点? 私有构造函数

如何将此行翻译成精灵?

var a = new Singleton ();

0 个答案:

没有答案
相关问题