The following function compiles fine in xcode, but in Fire I get an syntax error at
the first case statement.
func asNumber(_ thing:AnyObject)->Double?{
let ret:Double?
switch thing {
case is Int:
ret = Double(thing as! Int)
case let f as Float:
ret = Double(f)
default:
ret = nil
}
return ret
}
If I try, to compile this version of the function:
func asNumber(_ thing:AnyObject)->Double?{
let ret:Double?
switch thing {
//case is Int:
// ret = Double(thing as! Int)
case let f as Float:
ret = Double(f)
default:
ret = nil
}
return ret
}
, then again: xcode is fine, but fire expects a colon, where the “as” keyword is.
According to documentation (look for the example with the big switch statement), xcode seems to be right.
doc:
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/TypeCasting.html#//apple_ref/doc/uid/TP40014097-CH22-ID342
My Fire version:9.0.97.2071(master)
My Xcode version: 8.2.1(8C1002)