Singleton: Difference between revisions

m
→‎{{header|Julia}}: an older version 0.4 version syntax example got marked as incorrect, so updated.
m (→‎{{header|Julia}}: an older version 0.4 version syntax example got marked as incorrect, so updated.)
Line 1,140:
 
=={{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:
<lang julia>
typestruct IAmaSingleton end
 
x = IAmaSingleton()
4,102

edits