How could I split a string over multiple lines such as below?
var text:String = \"This is some text
over multiple lines\"
As pointed out by litso, repeated use of the +
-Operator in one expression can lead to XCode Beta hanging (just checked with XCode 6 Beta 5): Xcode 6 Beta not compiling
An alternative for multiline strings for now is to use an array of strings and reduce
it with +
:
var text = ["This is some text ",
"over multiple lines"].reduce("", +)
Or, arguably simpler, using join
:
var text = "".join(["This is some text ",
"over multiple lines"])