Peter
04/05/2023, 5:13 PMany.takeIf<Int>()
Youssef Shoaib [MOD]
04/05/2023, 5:35 PMinline fun <reified T> Any.takeIf(): T? = if (this is T) this else null
Ruckus
04/05/2023, 5:35 PMPeter
04/05/2023, 5:44 PMtakeIf
mislead me a bit. I guess as?
is perfectly ok. I'm using it like so: (any as? User)?.id
I guess doing any.takeIf<User>()?.id
doesn't really make it more readable.Gleb Minaev
04/05/2023, 6:56 PM.takeIf { it is MyType }
.