Last active
August 29, 2015 14:24
-
-
Save Blaisorblade/6a0f9501e343c1013a36 to your computer and use it in GitHub Desktop.
Playing with Scala cakes (?)
This file contains 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 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