Slide 60
Slide 60 text
case class Customer(
id : Long,
name : String,
phone : String
)
case class CustomerPatch(
name : Option[String],
phone : Option[String]
)
trait Merge[Into, From] {
def merge(i: Into, f: From): Into
}
def merge[Into, From](i: Into, f: From)
(implicit m: Merge[Into, From]) = m.merge(i, f)
implicit def customerMerge: Merge[Customer, CustomerPatch] =
???
merge(
Customer(1, "Bob", "555-123"),
CustomerPatch(Some("Robert"), None)
)
Customer(1, "Robert", "555-123")