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

November 2025

S M T W T F S
       1
23456 7 8
9 1011 12 1314 15
16171819 20 2122
23242526272829
30      

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Nov. 21st, 2025 08:16 pm
Powered by Dreamwidth Studios