Hacker News new | past | comments | ask | show | jobs | submit login

That's actually a really clever mechanism. Although it'll make the common case (basic string interpolation, no need for security concerns) more complicated unless a lot of APIs support a StringTemplate overload.



This could be supported with String constructor with StringTemplate overload.

    String str = new String("Hello \{name}");
OR just add a .interpolate() function

    String str = "Hello \{name}".interpolate(); // verbose
    String str = "Hello \{name}".join(); // less verbose, but less representative
OR probably at the bottom of the list of recommendations

    String str = "Hello \{name}".toString() // matches StringBuilder behaviour
Knowing Java devs, also a non-zero chance it becomes

    String str = "Hello \{name}".toUnsafeString()
Quoting Brian:

> shed to be painted (but please, not right now.).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: