Swift Language Upcasting


Example

The as operator will cast to a supertype. As it cannot fail, it does not return an optional.

let name = "Ringo"
let value = string as Any  // `value` is of type `Any` now