更新时间:2023-11-30 17:49:46
没有运算符,但是您可以使用pow函数,如下所示:
There isn't an operator but you can use the pow function like this:
return pow(num, power)
如果愿意,还可以让操作员像这样调用pow函数:
If you want to, you could also make an operator call the pow function like this:
infix operator ** { associativity left precedence 170 }
func ** (num: Double, power: Double) -> Double{
return pow(num, power)
}
2.0**2.0 //4.0