标签:swift error
1. Swift报错: Swift Compiler Error Binary oprator ‘+‘ cannot be applied to operands of type ‘UInt16‘ and ‘UInt8‘
错误写法:
let a:UInt16 = 1_000
let b: UInt8 =1
let sum = a + b
println("sum = \(sum)")
正确写法:
let a:UInt16 = 1_000
let b: UInt8 =1
let sum = a + UInt16(b)
println("sum = \(sum)")
2. Swift报错: Swift Compiler Error Binary oprator ‘+‘ cannot be applied to operands of type ‘Int‘ and ‘Double‘
错误写法:
let a = 123
let b = 0.456
let sum = a + b
println("sum = \(sum)")
正确写法:
let a = 123
let b = 0.456
let sum = Double(a) + b
println("sum = \(sum)")
版权声明:本文为博主原创文章,未经博主允许不得转载。
Swift Compiler Error Binary oprator '+' cannot be applied to operands of type 'UInt16' and 'UInt8'
标签:swift error
原文地址:http://blog.csdn.net/soindy/article/details/46772445