Skip to content

Instantly share code, notes, and snippets.

@tstone
Last active August 29, 2015 14:04
Show Gist options
  • Save tstone/1d912a2f3a49760da51f to your computer and use it in GitHub Desktop.
Save tstone/1d912a2f3a49760da51f to your computer and use it in GitHub Desktop.
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