手把手带你学习Swift3.0(5):类型强制转换

//: Playground - noun: a place where people can play

import UIKit

let m = 20
let n = 10.5

// let result = m + n 错误写法
// 将Int类型转成Double: Double(标识符)
// 将Double类型转成Int : Int(标识符)
let result1 = Double(m) + n
let result2 = m + Int(n)


let a : Double = 2.44
let b : CGFloat = 3.55

let result = a + Double(b)

你可能感兴趣的:(手把手带你学习Swift3.0(5):类型强制转换)