Created
August 7, 2015 23:29
-
-
Save matthewcheok/33e9e4f24a99f8b31cd4 to your computer and use it in GitHub Desktop.
Type promotion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fill in the blanks with mismatched lhs and rhs types | |
func +(lhs: Int, rhs: Double) -> Double { | |
return Double(lhs) + rhs | |
} | |
func +(lhs: Double, rhs: Int) -> Double { | |
return lhs + Double(rhs) | |
} | |
func +(lhs: Int, rhs: Float) -> Float { | |
return Float(lhs) + rhs | |
} | |
func +(lhs: Float, rhs: Int) -> Float { | |
return lhs + Float(rhs) | |
} | |
let r = Int(1) + Double(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment