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

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.

主站蜘蛛池模板: 共和县| 开原市| 乌拉特后旗| 永宁县| 盈江县| 红安县| 温州市| 浑源县| 广河县| 自贡市| 乾安县| 礼泉县| 英超| 沙坪坝区| 衡南县| 石楼县| 嘉鱼县| 澄江县| 永和县| 仁化县| 和田市| 平顶山市| 布尔津县| 枞阳县| 子长县| 温州市| 保康县| 临漳县| 古交市| 尚志市| 东方市| 固安县| 集贤县| 南安市| 于都县| 桐乡市| 吉林市| 肃宁县| 邢台县| 镇康县| 武城县|