as?
also can be used for cases where the cast might fail, because the object
is of the wrong type. In that case, as?
evaluates to null
, instead of to
the object. So, in this case, since kermit
is not an Axolotl
, notAnAxolotl
winds up null
.
You can learn more about this in:
Tags: