在XCode beta 5中,当我在操场上执行以下代码时:
import Swift
let a = UInt(0)
let b = UInt(0)
var string = ""
string += a + b > 1 ?
"true" :
"false"
let bool = a - b > 1
string += bool ?
"true" :
"false"
string = a - b > 1 ?
"true" :
"false"
string += a - b > 1 ? //ERROR
"true" :
"false"
我收到以下错误:
Playground execution failed: /var/folders/ws/cpskvst94cq5fb0vjmljzmkw0000gn/T/./lldb/41335/playground29.swift:10:13: error: ambiguous use of operator '-'
string += a - b > 1 ?
^
Swift.-:1:6: note: found this candidate
func -<T : Strideable>(lhs: T, rhs: T) -> T.Stride
^
Swift.-:1:6: note: found this candidate
func -<T : _DisallowMixedSignArithmetic>(lhs: T, rhs: T) -> T._DisallowMixedSignArithmetic
这是打算吗?为什么只有最后一行产生错误?