Skip to content

Instantly share code, notes, and snippets.

@joescii
Created April 6, 2015 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joescii/63a8a53ac0c5a46fb05a to your computer and use it in GitHub Desktop.
Save joescii/63a8a53ac0c5a46fb05a to your computer and use it in GitHub Desktop.
Dynamic traits
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