Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Singleton/Vala/singleton.vala
Normal file
24
Task/Singleton/Vala/singleton.vala
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
public class Singleton : Object {
|
||||
static Singleton? instance;
|
||||
|
||||
// Private constructor
|
||||
Singleton() {
|
||||
|
||||
}
|
||||
|
||||
// Public constructor
|
||||
public static Singleton get_instance() {
|
||||
if (instance == null) {
|
||||
instance = new Singleton();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
Singleton a = Singleton.get_instance();
|
||||
Singleton b = Singleton.get_instance();
|
||||
if (a == b) {
|
||||
print("Equal.\n");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue