官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 乾安县| 台安县| 甘德县| 南丹县| 剑川县| 宁河县| 七台河市| 福州市| 建水县| 罗甸县| 黄平县| 武定县| 泉州市| 富裕县| 东丽区| 漳州市| 梓潼县| 苍梧县| 南汇区| 乌恰县| 梧州市| 尚义县| 含山县| 崇文区| 宜黄县| 平潭县| 日照市| 玛纳斯县| 广元市| 永川市| 天水市| 惠来县| 磐石市| 临颍县| 犍为县| 石泉县| 台中市| 民丰县| 扬州市| 天峨县| 綦江县|