这段 Vala 代码,我从rosettacode中读到的
public class Singleton : Object {
static Singleton? instance;
Singleton() { } // Private constructor
public static Singleton get_instance() {
if (instance == null) {
instance = new Singleton();
}
return instance;
}
}
瓦拉:
var a = new Singleton ();
会输出错误
错误:访问私有成员“Singleton.new”被拒绝
如何在精灵中做到这一点?私有构造函数?
如何将这条线翻译成精灵?
Singleton() { } // Private constructor