I think I'd prefer it if it acted like `as?` and n...
# stdlib
k
I think I'd prefer it if it acted like
as?
and not
as
. I'd rather have to use the safe-call operator than potentially hide an exception.
Copy code
inline fun <reified R : Any> Any?.cast(): R? = this as? R
Usage:
Copy code
list.firstOrNull()?.cast<Foo>()?.bar