precedencegroup PowerPrecedence {
higherThan: MultiplicationPrecedence
associativity: right
}
infix operator **: PowerPrecedence
func **(base: Double, power: Double) -> Double {
return pow(base, power)
}
higherThan: MultiplicationPrecedence
associativity: right
}
infix operator **: PowerPrecedence
func **(base: Double, power: Double) -> Double {
return pow(base, power)
}
2017-08-18
Swift3 自定义双目运算符指定结合规则和优先级的方式改了,都封装在 precedencegroup 里,视频中的例子变成这样了:
infix operator **: MultiplicationPrecedence
func **(base: Double, power: Double) -> Double {
return pow(base, power)
}
其中 MultiplicationPrecedence 表示按乘除法的结合规则和优先级,对应加减法是:AdditionPrecedence
infix operator **: MultiplicationPrecedence
func **(base: Double, power: Double) -> Double {
return pow(base, power)
}
其中 MultiplicationPrecedence 表示按乘除法的结合规则和优先级,对应加减法是:AdditionPrecedence
2017-08-18