Given this function:
func anInt() -> Int {
return 5
}
This doesn't work:
anInt() / Double(2)
>> ERROR: Could not find an overload for '/' that accepts the supplied arguments
However this works:
5 / Double(2)
>> 2.5
When you call anInt() / Double(2) the compiler knows you are trying divide an Int by a Double and doesn't allow that, but when you call 5 / Double(2), it can infer the type of 5 as a Double since you are dividing it by a Double.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With