【发布时间】:2018-11-16 19:44:16
【问题描述】:
为什么 Swift Int 扩展中不允许使用 max(::) 和 min(::),例如:
extension Int {
func some(low: Int, high: Int) -> Int {
return max(low, high)
}
}
错误提示:Static member 'max' cannot be used on instance of type'Int'
【问题讨论】:
-
比较stackoverflow.com/q/39602298/2976878——你现在必须说
Swift.max(low, high)。 -
编译器在这里需要一些帮助。它认为你的意思是developer.apple.com/documentation/swift/int/1540171-max
标签: swift max min instancetype