16

I am new to Swift. The docuentation says: Use three double quotes (""") for strings that take up multiple lines. Indentation at the start of each quoted line is removed, as long as it matches the indentation of the closing quote. For example:

let quotation = """
Even though there's whitespace to the left,
the actual lines aren't indented.
Except for this line.
Double quotes (") can appear without being escaped.
I still have \(apples + oranges) pieces of fruit.
"""

However, I copied this example and pasted in my xcode playground and it shows an error:

Playground execution failed: error: SwiftBasics.playground:9:19: error: 
unterminated string literal
let quotation = """

What am I doing wrong ?

jreft56
  • 199
  • 1
  • 12

1 Answers1

28

I assume you are using Xcode 8 or earlier. Multi line String Literals have been implemented in Swift 4. You can only use them with Xcode 9 Beta or by including the open source Swift 4 toolchain in your Xcode at the moment.

Jens Meder
  • 4,237
  • 1
  • 25
  • 25