Created
February 21, 2012 07:46
-
-
Save kencoba/1874918 to your computer and use it in GitHub Desktop.
Prototype 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
@cloneable | |
class Command(value: Int, name: String) { | |
override def clone = super.clone | |
override def toString = value + ": " + name | |
} | |
object Main { | |
def main(args: Array[String]) = { | |
val com1 = new Command(1, "Hoge") | |
val com2 = com1.clone | |
println(com1) | |
println(com2) | |
println(com1 eq com2) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does not work, may it's for some old version of scala.