Skip to content

Instantly share code, notes, and snippets.

@Phil-Ba
Created March 10, 2017 09:58
Show Gist options
  • Save Phil-Ba/e841accdfbcd5f7ddfd0cd605da213ef to your computer and use it in GitHub Desktop.
Save Phil-Ba/e841accdfbcd5f7ddfd0cd605da213ef to your computer and use it in GitHub Desktop.
trait Printer {
def print(s: String) = println(s)
}
trait UpperPrinter extends Printer {
override def print(s: String) = super.print(s.toUpperCase)
}
trait DoublePrinter extends Printer {
override def print(s: String) = super.print(s * 2)
}
trait PrettyPrinter extends Printer {
override def print(s: String) = super.print(s"*** $s ***")
}
val x = new {} with Printer with PrettyPrinter with DoublePrinter
x.print("hello")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment