Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Partial updates with immutable domain objects
case class Person(val firstName: String, val lastName: String, val age: Int, val email: String) {
def update(firstName: String = firstName, lastName: String = lastName, age: Int = age, email: String = email) : Person = {
Person(firstName, lastName, age, email)
val seedPerson = Person("A", "B", 1, "")
val updatedPerson = seedPerson update (age = 100, firstName = "Z")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.