Forked from anonymous/AmbiguousStringAdd.scala
Last active
December 10, 2015 16:18
-
-
Save puffnfresh/4460098 to your computer and use it in GitHub Desktop.
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
import language.implicitConversions | |
class AmbiguousStringAdd { | |
def +(b: String) = ??? | |
} | |
implicit def amb1any2stringadd(a: Any) = new AmbiguousStringAdd | |
implicit def amb2any2stringadd(a: Any) = new AmbiguousStringAdd | |
class A {} | |
// Won't compile! | |
// println(new A + "ASDF") | |
// println(true + "ASDF") | |
// Sadly, scala.Int and scala.Double have +(x: String) defined | |
println(1 + "ASDF") | |
println(2.3 + "ASDF") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment