gpt4 book ai didi

Swift 三个双引号

转载 作者:IT王子 更新时间:2023-10-29 05:20:50 25 4
gpt4 key购买 nike

我是 Swift 的新手。文档说:对占用多行的字符串使用三个双引号 (""")。每个引用行开头的缩进被删除,只要它与结束引号的缩进匹配。例如:

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 或更早版本。 Multi line String Literals已在 Swift 4 中实现。您目前只能将它们与 Xcode 9 Beta 一起使用,或者通过在 Xcode 中包含开源 Swift 4 工具链来使用。

关于Swift 三个双引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44397374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com