https://kotlinlang.org logo
#announcements
Title
# announcements
e

Eric O'Connell

01/18/2019, 6:57 PM
question … is there anything in stdlib like this (definitely not sold on the name… maybe
doIfNull
is clearer)?
Copy code
fun <T> T?.orElse(ifNull: () -> Unit): T? {
    if (this == null) {
        ifNull()
    }
    return this
}