Jump to content

Singleton: Difference between revisions

Add Scala example
m (omit ocaml)
(Add Scala example)
Line 448:
b = MySingleton.instance
puts a.equal?(b) # outputs "true"</lang>
 
=={{header|Scala}}==
 
The '''object''' construct in Scala is a singleton.
 
<lang scala>
object Singleton {
// any code here gets executed as if in a constructor
}
</lang>
 
=={{header|Slate}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.