karelpeeters
08/21/2017, 11:45 AMarekolek
08/21/2017, 11:52 AMfoo.takeIf { it is Foo }
for those cases where foo
is a “property with an open or custom getter”foo.let { if (it is Foo) }
which is not too badlovis
08/21/2017, 12:17 PMinline fun <reified T> Any.takeIfInstance() = this.takeIf { it is T } as? T
should work
call it val astring = myObj.takeIfInstance<String>()
karelpeeters
08/21/2017, 12:18 PMlovis
08/21/2017, 12:18 PMfilterIsInstance
mapIsInstance
ilya.gorbunov
08/22/2017, 7:32 AMfoo as? Foo