Singleton: Difference between revisions

Content added Content deleted
(→‎{{header|C++}}: A proper implementation should only (1) ensure that only one instance exists at any given moment; and (2) provide global access to that instance. Concurrency issues should be considered as a separate matter (in the general case).)
mNo edit summary
Line 1,138: Line 1,138:


document.write( (new Singleton()).get() );</lang>
document.write( (new Singleton()).get() );</lang>

=={{header|Julia}}==
Julia allows singletons as type declarations without further specifiers. There can be only one instance of such a type, and if more than one variable is bound to such a type they are actually all bound to the same instance in memory:
<lang julia>
type IAmaSingleton end

x = IAmaSingleton()
y = IAmaSingleton()

println("x == y is $(x == y) and x === y is $(x === y).")
</lang>


=={{header|Kotlin}}==
=={{header|Kotlin}}==