Instantly share code, notes, and snippets.

What would you like to do?
Type promotion
// 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