Created
April 6, 2015 15:58
-
-
Save joescii/63a8a53ac0c5a46fb05a to your computer and use it in GitHub Desktop.
Dynamic traits
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 Base | |
trait Child1 extends Base { | |
def method1:String = "method1" | |
} | |
trait Child2 extends Base { | |
def method2:String = "method2" | |
} | |
def coinFlip:Boolean = ??? | |
val thing:String with Base = if(coinFlip) new String("str") with Child1 | |
else new String("str") with Child2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment