Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Singleton/EMal/singleton.emal
Normal file
17
Task/Singleton/EMal/singleton.emal
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
type Singleton
|
||||
model
|
||||
text greeting
|
||||
fun speak = void by block do writeLine(me.greeting + " I'm a singleton") end
|
||||
end
|
||||
Singleton instance
|
||||
fun getInstance = Singleton by block
|
||||
if instance == null do instance = Singleton() end
|
||||
return instance
|
||||
end
|
||||
type SomeOtherType
|
||||
Singleton s1 = Singleton.getInstance()
|
||||
s1.greeting = "Hello"
|
||||
Singleton s2 = Singleton.getInstance()
|
||||
s2.greeting.append(", World!")
|
||||
writeLine(s1 + " and " + s2 + " are the same object: " + (s1 == s2) + ", s2: " + s2.greeting)
|
||||
s1.speak() # call instance method
|
||||
Loading…
Add table
Add a link
Reference in a new issue