Multiline String Literals
Write readable multiline text with triple quotes.
Multiline String Literals
A multiline string literal spans several lines. It is delimited by three double-quote marks on their own lines, and the text in between keeps its line breaks.
let poem = """
Roses are red
Violets are blue
"""
print(poem)Preserving Line Breaks
Each newline you type inside the literal becomes a newline in the resulting string, so formatting is preserved exactly.
let menu = """
Coffee
Tea
Water
"""
print(menu)All lessons in this course
- Basic String Interpolation
- Formatting Numbers in Strings
- Multiline String Literals
- Custom String Interpolation