我是斯威夫特的新手。该文档说:对于占用多行的字符串,请使用三个双引号 (""")。只要与结束引号的缩进相匹配,每个带引号的行开头的缩进就会被删除。例如:
let quotation = """
Even though there's whitespace to the left,
the actual lines aren't indented.
Except for this line.
Double quotes (") can appear without being escaped.
I still have \(apples + oranges) pieces of fruit.
"""
但是,我复制了这个示例并粘贴到我的 xcode Playground 中,它显示了一个错误:
Playground execution failed: error: SwiftBasics.playground:9:19: error:
unterminated string literal
let quotation = """
我究竟做错了什么 ?
我假设您使用的是 Xcode 8 或更早版本。多行字符串文字 https://github.com/apple/swift-evolution/blob/master/proposals/0168-multi-line-string-literals.md已在 Swift 4 中实现。您目前只能将它们与 Xcode 9 Beta 一起使用,或者将开源 Swift 4 工具链包含在 Xcode 中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)