Example:
class Node {
def cls(c: String): this. type = { whatever; this }
}
Regards,
Jan
> Use this.type.
>
> Example:
>
> class Node {
> def cls(c: String): this. type = { whatever; this }
> }
>
this.type means “exactly this object”, which does not fit the OP’s requirements (return updated copy). Unfortunately, the issue is not a simple one, search this group for MyType. In essence you would need to go the same route as the collections library (using the CanBuildFrom pattern).
Regards,
Roland
Roland Kuhn
Typesafe – The software stack for applications that scale.
twitter: @rolandkuhn