Using multiple let-as within a if-statement in Swift

前端 未结 3 553
天命终不由人
天命终不由人 2020-12-07 13:18

I\'m unwrapping two values from a dictionary and before using them I have to cast them and test for the right type. This is what I came up with:

var latitude         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 14:04

    Swift 3.0

    if let latitudeDouble = latitude as? Double, let longitudeDouble = longitude as? Double {
        // do stuff here
    }
    

提交回复
热议问题