Because force casting (as!
) does not perform any type safety validations, it is capable of performing dangerous conversions between
unrelated types. When the types are truly unrelated, the cast will cause a system crash.
Noncompliant code example
foo as! MyClass // Noncompliant
Compliant solution
foo as? MyClass