This is an automated archive made by the Lemmit Bot.
The original was posted on /r/java by /u/repeating_bears on 2023-10-26 19:18:44.
I’ve been using Java 15’s text blocks recently. Why was there the requirement for an initial newline after the """
?
I understand that the main use-case is for strings that span multiple lines, but it’s also useful for single-line strings that make heavy use of double quotes, e.g. JSON, removing the need to escape them.
What would have been the problem with allowing this?
String json = """{"foo":"bar","bar":123}""";
Right now, I have to write
String json = """
{"foo":"bar","bar":123}""";
It’s not a problem, just waste of space. Is there some compatibility issue I’m missing or what? Unless I missed it, the JEP provides no justification. I searched the mailing list but couldn’t find anything.
I know this is trivial but I’m curious anyway.
You must log in or register to comment.