Skip to content

Instantly share code, notes, and snippets.

@kencoba
Created February 21, 2012 07:46
Show Gist options
  • Save kencoba/1874918 to your computer and use it in GitHub Desktop.
Save kencoba/1874918 to your computer and use it in GitHub Desktop.
Prototype pattern (Design Patterns in Scala)
@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)
}
}
@Ehsan1997
Copy link

Does not work, may it's for some old version of scala.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment