mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
18 lines
322 B
Kotlin
Vendored
18 lines
322 B
Kotlin
Vendored
// WITH_RUNTIME
|
|
|
|
// FILE: test.kt
|
|
|
|
fun test1() {
|
|
val u = Unit
|
|
u.mapNullable({ "X1" }, { "X2" })
|
|
}
|
|
|
|
// @TestKt.class:
|
|
// 0 IFNULL
|
|
// 0 IFNONNULL
|
|
// 1 X1
|
|
// 0 X2
|
|
|
|
// FILE: inline.kt
|
|
inline fun <T : Any, R> T?.mapNullable(ifNotNull: (T) -> R, ifNull: () -> R) =
|
|
if (this == null) ifNull() else ifNotNull(this) |