castOrNull

inline fun <T> Any?.castOrNull(): T?

Casts Any to a type T or returns null.

Chained function call alternative to this as? T.

Return

The cast value of type T or null if the cast fails.

See also