Skip to content

Instantly share code, notes, and snippets.

@paulp
Created September 14, 2014 03:08
Show Gist options
  • Save paulp/36b67d27400a9f3be96a to your computer and use it in GitHub Desktop.
Save paulp/36b67d27400a9f3be96a to your computer and use it in GitHub Desktop.
class Bippy(override val toString: String)
trait A { implicit def lowPriority: Bippy = new Bippy("A") }
object B extends A { implicit def highPriority: Bippy = new Bippy("B") }
object C { implicit def highPriority: Bippy = new Bippy("C") }
object Test {
def main(args: Array[String]): Unit = {
import B._, C._
println( implicitly[Bippy] ) // Prints: A
}
}
@som-snytt
Copy link

Literate programming:

object B extends A { implicit def `the one where B introduces a better bippy`: Bippy = new Bippy("B") }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment