In many languages multiline String literal syntax is
"""
Hello
World
"""
But why it require a new syntax, why just not to use "
instead of """
?
Like:
"Hello
World"
In many languages multiline String literal syntax is
"""
Hello
World
"""
But why it require a new syntax, why just not to use "
instead of """
?
Like:
"Hello
World"
I think this is primarily to allow nested double quotes:
"""
Hello, "World"
"""
If "
was used for multiline strings, then you had to escape nested quotes which is a bit inconvenient.
You can simply include formatted code like this:
val text = """
for (c in "foo")
print(c)
"""
or use special chars like "
without the need to escape. It's very neat when it comes to JSON for example.