2013-07-07

juan_gandhi: (VP)
2013-07-07 09:42 am
Entry tags:

just learned

case classes in Scala have a method copy

Neat, nice, nifty!

Now the question is: why would one need it, in case the class is immutable?!

This is why
  case class Person(first: String, second: String)
  val p1 = Person("John", "Waters")
  val p2 = p1.copy(first="James")