Last active
August 29, 2015 14:04
-
-
Save tstone/1d912a2f3a49760da51f to your computer and use it in GitHub Desktop.
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 characters
trait Example { self => | |
def mode(m: String): self.type | |
} | |
case class Foo extends Example { | |
def mode(m: String) = this.copy(mode = m) | |
} | |
// abstract type, polymorhpic | |
trait Example[A] { | |
def mode(m: String): A | |
} | |
case class Foo extends Example[Foo] { | |
def mode(m: String) = this.copy(mode = m) | |
} | |
// abstract type, implementation | |
trait Example { | |
type A | |
def mode(m: String): A | |
} | |
case class Foo extends Example { | |
type A = Foo | |
def mode(m: String) = this.copy(mode = m) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment