Skip to content

Instantly share code, notes, and snippets.

@pedrofurla
Last active June 11, 2016 15:06
Show Gist options
  • Save pedrofurla/d399c76c68c9b4e03283fe121c7afbb5 to your computer and use it in GitHub Desktop.
Save pedrofurla/d399c76c68c9b4e03283fe121c7afbb5 to your computer and use it in GitHub Desktop.
Where String#+ comes from?
object Tmp {
"zzz" ++ "kkk" // Fails with -Yno-predef
// after typer the above is scala.this.Predef.augmentString("zzz").++[Char, String](scala.this.Predef.augmentString("kkk"))(scala.this.Predef.StringCanBuildFrom);
"aaa"+new Object() // Doesn't fail ever!
// after typer the above is "aaa".+(new java.this.lang.Object());
// Why didn't `+` desugar to something else?
new Object() + "aaa" // Fails with -Yno-predef
// after typer the above is scala.this.Predef.any2stringadd[Object](new java.this.lang.Object()).+("aaa");
// import Predef.{any2stringadd => _, StringAdd => _, augmentString => _, _}
}
@pedrofurla
Copy link
Author

Awesome, cool!

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