Created
February 1, 2014 12:05
-
-
Save matthandlersux/8751399 to your computer and use it in GitHub Desktop.
Revisions
-
matt handler created this gist
Feb 1, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ trait Base[T] { val id: Option[String] def copyId(id: String): T } case class Test2(id: Option[String], other: String) extends Base[Test2] { def copyId(id: String) = copy(id=Some(id)) } def updateId[T <: Base[T]](obj: T, id: String) = obj.copyId(id) val y = Test2(None, "hmm") assert(updateId(y, "!!!") == Test2(Some("!!!"), "hmm"))