Swift 中 Int 扩展中的 max(_:_:) 和 min(_:_:)

max(_:_:) and min(_:_:) in an Int extension in Swift

为什么 max(::) 和 min(::) 在 Swift Int 扩展中不允许,如:

extension Int {
    func some(low: Int, high: Int) -> Int {
        return max(low, high)
    }
}

错误说:Static member 'max' cannot be used on instance of type'Int'

编译器在这里需要一些帮助。它认为你的意思是 https://developer.apple.com/documentation/swift/int/1540171-max

正如 Hamish 所说,您可以在此上下文中消除歧义,通过调用它来指定全局函数 Swift.max