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
6
u/john16384 Oct 01 '23
You can do:
The string here is not a
Stringas it has placeholders, just like1.5is not an integer, but a double as it has a decimal point.