简单类型 / 字符串

func testString() {
    let multilineString = """
    1. First line
    2. Second \
    line
        3. Third line
    4. Fourth "line"
    """

    print(multilineString)
}

testString()

//prints:
//1. First line
//2. Second line
//    3. Third line
//4. Fourth "line"


If you need a string that spans several lines, use a multiline string literal — a sequence of characters surrounded by three double quotation marks. The string begins on the first line after the opening quotation marks (""") and ends on the line before the closing quotation marks.

If you want to use line breaks to make your source code easier to read, but you don’t want the line breaks to be part of the string’s value, write a backslash (\) at the end of those lines.