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

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.

主站蜘蛛池模板: 大化| 潮安县| 永昌县| 华容县| 平乐县| 夏津县| 尚志市| 顺义区| 定边县| 安丘市| 腾冲县| 上林县| 平阳县| 双峰县| 吉木萨尔县| 新疆| 漳州市| 清河县| 永仁县| 黔西县| 泸定县| 白朗县| 高雄县| 太保市| 大连市| 南昌市| 南汇区| 含山县| 溆浦县| 泾阳县| 北辰区| 玉屏| 隆子县| 丰城市| 曲沃县| 东山县| 修水县| 岳西县| 井冈山市| 遂平县| 平谷区|