Extend to cope with double + float

This commit is contained in:
Jonathan Guthrie 2018-04-19 13:55:59 -04:00
parent 8e6777dc4e
commit fea3e9c026
1 changed files with 6 additions and 0 deletions

View File

@ -43,6 +43,12 @@ extension StORM {
// Double // Double
// ======================================================================================= // =======================================================================================
public static func double(_ data: [String: Any], _ name: String, _ def: Double? = Double()) -> Double? { public static func double(_ data: [String: Any], _ name: String, _ def: Double? = Double()) -> Double? {
if let d = data[name] as? Float {
return Double(d)
} else if let d = data[name] as? Double {
return d
}
return Double((data[name] as? Float) ?? Float(def ?? 0.00)) return Double((data[name] as? Float) ?? Float(def ?? 0.00))
} }