【发布时间】:2023-03-03 06:07:21
【问题描述】:
我最近在 Swift 5 Book 上发现了这段代码 sn-ps。
print(#"Write an interpolated string in Swift using \(multiplier)."#)
// Prints "Write an interpolated string in Swift using \(multiplier).”
print(#"6 times 7 is \#(6 * 7)."#)
// Prints "6 times 7 is 42.”
我了解到它是 Swift 5 中公认的 proposal,用于增强字符串文字分隔符以支持原始文本,并给出了很多示例。
我的问题是在实际案例中何时以及如何使用它,因为从上面给出的示例中,即使没有# 标志,我仍然可以清楚地实现我想要的!
【问题讨论】:
标签: string delimiter swift5 rawstring