withCast

inline fun <T : Any, R> Any?.withCast(block: T.() -> R): R?

See also