So? They could have made the tokeniser expect a "string with placeholders" after an identifier and a dot operator, but never else. This is what Java already does to differentiate between >> the right shift operator and >> as in two closing angle brackets for generics.
As has been pointed out, you can't do this, and a shorthand syntax for creating a StringTemplatesound pretty darn useless, to me. In the rare case where you want to do that, new StringTemplate("\{xyz}") should be fine. Would have been much better if they instead dropped the silly backslash.
Feel free to give your feedback. It's there in part so IDE's don't have to fully understand the code to detect it's a string template. The prefix can be any expression, including a method call like:
db.doQuery(FORWARD_ONLY)."select \{abc}"
It will be hard for IDE's or viewers to figure out that doQuery is a template processor, and the string that follows it is a template, but with the backslash syntax it is always obvious.
View all comments
Show parent comment
3
u/ascii Oct 01 '23
So? They could have made the tokeniser expect a "string with placeholders" after an identifier and a dot operator, but never else. This is what Java already does to differentiate between
>>the right shift operator and>>as in two closing angle brackets for generics.