Weekly Swift articles, podcasts and tips by John Sundell.

Multiline string literals

Published on 27 Aug 2018
Basics article available: Strings

One really nice benefit of Swift multiline string literals - even for single lines of text - is that they don't require quotes to be escaped. Perfect when working with things like HTML, or creating a custom description for an object.

let html = highlighter.highlight("Array<String>")

XCTAssertEqual(html, """
<span class="type">Array</span><<span class="type">String</span>>
""")