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

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.

主站蜘蛛池模板: 衡水市| 桃园市| 寿阳县| 东乡族自治县| 大邑县| 万载县| 古交市| 崇仁县| 册亨县| 龙井市| 临漳县| 惠水县| 四子王旗| 封开县| 长治市| 台安县| 保康县| 壤塘县| 迁安市| 莒南县| 秭归县| 双流县| 仁化县| 丰宁| 五大连池市| 湖州市| 曲阜市| 张掖市| 原阳县| 蚌埠市| 叙永县| 湘潭县| 射阳县| 乌拉特中旗| 克山县| 阜城县| 敦煌市| 云南省| 靖江市| 泸水县| 云和县|