2 ms·
It seems to be using a somewhat similar concept it calls "incidental white space", in order to limit the embedding of leading whitespace (unlike Python which ju
by masklinn 7y ago
It seems to be using a somewhat similar concept it calls "incidental white space", in order to limit the embedding of leading whitespace (unlike Python which just stores the entire triple-quoted string as-is), but is more permissive:
Text content can be indented less than the trailing delimiter, which I understand is an error in Swift
String html = """
..............<html>
.............. <body>
.............. <p>Hello, world</p>
.............. </body>
..............</html>
.............. """;
The trailing delimiter can also be on the same line as the final content, which suppresses the final (new)line:
"""
line 1
line 2
line 3"""
translates to
"line 1\nline 2\nline 3"
whereas
"""
line 1
line 2
line 3
"""
translates to
"line 1\nline 2\nline 3\n"
I believe this requires escaping the newline in Swift instead (nb: according to the JEP this would also work in Java).
- _old_dude_ 7y agoSlash at the end of the line serve the same purpose in Java
- masklinn 7y ago> Slash at the end of the line serve the same purpose in Java As I wrote in my comment, yes.