Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -1,17 +1,17 @@
|
|||
type Singleton
|
||||
model
|
||||
text greeting
|
||||
fun speak = void by block do writeLine(me.greeting + " I'm a singleton") end
|
||||
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
|
||||
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()
|
||||
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)
|
||||
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