<@U6M6DATB5> There's this issue that's WIP, it's a...
# announcements
k
@arekolek There's this issue that's WIP, it's also about smart casts and inline functions: https://youtrack.jetbrains.com/issueMobile/KT-14397
👍 1
a
Thanks. I was thinking about things like
foo.takeIf { it is Foo }
for those cases where
foo
is a “property with an open or custom getter”
But I can write
foo.let { if (it is Foo) }
which is not too bad
l
write your own:
inline fun <reified T> Any.takeIfInstance() = this.takeIf { it is T } as? T
should work call it
val astring = myObj.takeIfInstance<String>()
k
Hmm that rings a bell, doesn't something like that exists already?
Maybe for filtering collections.
l
yes there is
filterIsInstance
and
mapIsInstance
(must have dreamt about the last one)
i
just use
foo as? Foo