Created
February 21, 2012 07:48
-
-
Save kencoba/1874937 to your computer and use it in GitHub Desktop.
Singleton pattern (Design Patterns in Scala)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Singleton { | |
var name: String = "" | |
} | |
object Main { | |
def main(args: Array[String]) { | |
var s1 = Singleton | |
var s2 = Singleton | |
println (s1 eq s2) | |
s1.name = "First" | |
println(s2.name) | |
} | |
} | |
Main.main(Array()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment