Dynamic Casting in Swift

Samuel E. Giddins: We can even define some syntactic sugar on top of this type verification: func id<U>(object: AnyObject) -> U? { if let typed = object as? U { return typed } return nil } […] OK, that last example might not look like a huge improvement, but coupled with Swift’s powerful type inference, … Continue reading Dynamic Casting in Swift