Jul. 7th, 2013

juan_gandhi: (VP)
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")

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

October 2025

S M T W T F S
    1 23 4
5 678 9 1011
12 13 1415 161718
1920 2122 23 2425
26 2728 293031 

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Oct. 31st, 2025 07:03 am
Powered by Dreamwidth Studios