- 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.
- 網店設計看這本就夠了
- Apex Design Patterns
- 零基礎學單片機C語言程序設計
- Mastering Linux Network Administration
- Elasticsearch Server(Third Edition)
- Visual Basic程序設計上機實驗教程
- Java Web開發詳解
- Android Wear Projects
- Vue.js 2 Web Development Projects
- Web App Testing Using Knockout.JS
- PHP+MySQL動態網站開發從入門到精通(視頻教學版)
- Mastering JavaScript
- 系統分析師UML用例實戰
- Android從入門到精通
- Android Application Programming with OpenCV 3