【发布时间】:2014-06-05 04:41:01
【问题描述】:
在玩 Swift 时,我发现了一些尴尬的错误。
let cost = 82.5
let tip = 18.0
let str = "Your total cost will be \(cost + tip)"
正如我所料,这可以正常工作,但是
let cost = 82.5
let tip:Float = 18
let str = "Your total cost will be \(cost + tip)"
不会出现错误
could not find member 'convertFromStringInterpolationSegment'
let str = "Your total cost will be \(cost + tip)"
两个示例之间的区别在于是否将tip 常量声明为显式浮动。这会是合理的结果吗?
【问题讨论】: