Float to Int
發表於 : 週一 12月 07, 2015 12:55 pm
代碼: 選擇全部
extension Float
{
func toInt() -> Int? {
if self > Float(Int.min) && self < Float(Int.max) {
return Int(self)
} else {
return nil
}
}
}