- Reactive Programming with Swift 4
- Navdeep Singh
- 168字
- 2021-06-24 18:58:00
Multiline String literals
With earlier versions of Swift, you had to use \n in your Strings to add line breaks, which meant if the String was very long, then your code would start looking ugly with heaps of \n sprinkled across it. Proposal SEO163 introduces multiline literals to Swift with a very simple syntax. Long Strings or multiline Strings are Strings delimited by triple quotes, that is, """ so we can say as follows:
let paragraph = """
This is a paragraph to demonstrate an example of multi-line String literals and the use in the latest Swift 4 syntax!
"""
So you have to end the multiline String literals with triple quotes as well, as shown in the preceding code. The nice part about these multiline String literals is that they can contain newlines, single quotes, nested, and unescaped double quotes without the need to escape them. As an example, you can include some sample JSON to test against without escaping every single quote.
- Learn ECMAScript(Second Edition)
- Python程序設計教程(第2版)
- 在最好的年紀學Python:小學生趣味編程
- SQL Server 2012數據庫技術及應用(微課版·第5版)
- Java深入解析:透析Java本質的36個話題
- EPLAN實戰設計
- 高級語言程序設計(C語言版):基于計算思維能力培養
- Go語言精進之路:從新手到高手的編程思想、方法和技巧(2)
- 計算機應用基礎案例教程
- Java語言程序設計教程
- Python大學實用教程
- IDA Pro權威指南(第2版)
- 青少年學Python(第2冊)
- Instant GLEW
- Python Penetration Testing Essentials