Last active
August 29, 2015 14:06
-
-
Save cb372/15053455fbf9700bd576 to your computer and use it in GitHub Desktop.
String concatenation is done very early
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
String concatenation happens before the tree is passed to your macro, | |
so you get passed a Literal(Constant("ab")) | |
scala> reify(() => "a" + "b") | |
res14: res0.universe.Expr[() => String] = Expr[() => java.lang.String]((() => "ab")) | |
This is not the case with other String ops. | |
I guess + is special because it's a Java operator, not a method on StringLike. | |
scala> reify(() => "a" * 5) | |
res15: res0.universe.Expr[() => String] = Expr[() => String]((() => Predef.augmentString("a").$times(5))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment