Avatar
Avatar
log5
@swift-5.7.3 @swift-5.2.5 import Foundation extension Int { func cbrt() -> Int { Int(pow(Double(self), 1 / 3)) // global の pow が呼ばれると思ってた... } func pow(fakeSignature: Void) { // こっちは引数が違うから呼ばれないと思ってた... } } print(2023.cbrt())
swift52 BOT 1/7/2023 2:32 PM
exit status: 1 with stderr:<stdin>:5:9: error: type '()' cannot conform to 'BinaryInteger'; only struct/enum/class types can conform to protocols Int(pow(Double(self), 1 / 3)) ^ <stdin>:5:9: note: required by initializer 'init(_:)' where 'T' = '()' Int(pow(Double(self), 1 / 3)) ^ <stdin>:5:33: error: extra argument in call Int(pow(Double(self), 1 / 3)) ~~^~~ <stdin>:5:17: error: cannot convert value of type 'Double' to expected argument type 'Void' Int(pow(Double(self), 1 / 3)) ^