News for hackers. Stuff that matters.
Re:Java string interpolation feature has been cancelled by MrJohz on Thursday June 20, 2024 @08:52AM (#40738187)
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.
Re:Java string interpolation feature has been cancelled by darylteo on Thursday June 20, 2024 @10:08AM (#40738966)
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.).