Allows to cast an expression from a type to another. There are 3 kind of as expression depending on the level of certitude.
First the simple cast. Nothing more than as followed by a type. It is to use when the compiler can deduce the cast as safe.
Then the as? when the compiler can’t say for sure it is safe. The output expression will be an optional.
Finally the as! when we say to the compiler: “It is my problem if it crash”. Of course if it crash an error would be thrown at runtime and it would be possible to catch it.
// example, no valid code
var a any = 42
i := a as int? // as with a optional is always valid; it is <=> to as?
i = a as? int // same thing
i = a as! int // we say to the compiler to not worie about the cast