How can I create a multiline string in Swift? This is what I tried:
var myMultilineString = "This is a " + "\n" + "multiline string"
print(myMultilineString)
I wanted it to print:
This is a
multiline string
Swift4 has this feature built in:
var myMultilineString =
"""
This is a
multiline string
"""
very convenient
If you want more than a line return between the strings but rather a real blank line, then you need two line feed characers.
var myMultilineString = "This is a " + "\n\n" + "multiline string"
print(myMultilineString)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With