https://twitter.com/kotlin/status/1384521745726640128
Kotlin 1.5 introduces new functions on collections: firstNotNullOf(OrNull).
They transform each element one by one, and return the first non-null result.
If no such result exists, firstNotNullOf throws an exception, *OrNull returns null.
#KotlinTips https://t.co/xGihNsx8Fv
Twitter
j
Joost Klitsie
04/20/2021, 2:59 PM
this is the greatest function name I have seen in a long time
😂 1
Joost Klitsie
04/20/2021, 2:59 PM
firstNotNullOfOrNull
is a proper mouthful
r
Rob Elliot
04/20/2021, 3:01 PM
Right up there with
AbstractSingletonProxyFactoryBean
.
➕ 1
m
Michael Böiers
04/20/2021, 3:02 PM
I like it. It’s cool that the name was chosen for consistency with the other method names instead of opting for a shorter name. If anything, it serves as an incentive to avoid nullable types, in which case it doesn’t need to be used. 🙂
m
marlonlom
04/20/2021, 3:17 PM
oh my... i wrote something similar usong high order functions haha