Singleton: Difference between revisions

Content added Content deleted
m (→‎{{header|Julia}}: an older version 0.4 version syntax example got marked as incorrect, so updated.)
Line 1,140: Line 1,140:


=={{header|Julia}}==
=={{header|Julia}}==
{{incorrect|Julia|ERROR: LoadError: syntax: extra token "IAmaSingleton" after end of expression}}
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:
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>
<lang julia>
type IAmaSingleton end
struct IAmaSingleton end


x = IAmaSingleton()
x = IAmaSingleton()