Skip to content

Instantly share code, notes, and snippets.

@Blaisorblade
Last active August 29, 2015 14:24
Show Gist options
  • Save Blaisorblade/6a0f9501e343c1013a36 to your computer and use it in GitHub Desktop.
Save Blaisorblade/6a0f9501e343c1013a36 to your computer and use it in GitHub Desktop.
Playing with Scala cakes (?)
trait Cake
/*
trait Slice[T <: Cake] {
val cake: T
import cake._
//... implement slice using methods from cake ...
}
trait CakeSlice extends Cake with Slice[Cake with this.type] {
val cake: this.type = this //this is not accepted???
}
*/
trait Slice {
type T <: Cake
val cake: T
import cake._
//... implement slice using methods from cake ...
}
trait CakeSlice extends Cake with Slice {
type T = this.type
val cake: this.type = this
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment