4 ms·
I wonder if lowercase "str." will work. Should be easier to type. I didn't find anything about that.
by GoToRO 4y ago
I wonder if lowercase "str." will work. Should be easier to type. I didn't find anything about that.
- MBCook 4y agoSTR seems to function like a class name, where you’re calling a static method. In fact that’s literally what you’re doing, but it seems to be syntactic sugar that you don’t have to write the method name and the parentheses. Since class names start with a capital it fits. At least I think that was the reasoning they stated. Why not Str? Perhaps they thought this would be less likely in existing code. I’m not sure I don’t think they mentioned the reason. They could have also just put it on the String class. Again I didn’t see a discussion as to why that wasn’t suggested. String.”Hello, \{name}.” Seems like it would have been reasonable. But this is a proposal so it may change before officially joining the JDK.
- zaphirplane 4y ago+1 The syntactic sugar should be a feature then used used here rather than invent a special cased syntax for a feature just use a conventional calling syntax. Java is a fairly verbose language with a highly verbose popular patterns
- kaba0 4y agoSTR is a static field, and the syntax sugar is equivalent of StringTemplate t = RAW.”Hello, \{name}.” STR.process(t);
- kaba0 4y agofinal var str = STR;