commonMain.extensions.Any.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluid-stdlib-tvosx64 Show documentation
Show all versions of fluid-stdlib-tvosx64 Show documentation
Potentially useful Kotlin standard library additions
package io.fluidsonic.stdlib
import kotlin.contracts.*
public inline fun Any.cast(): T {
contract {
returns() implies (this@cast is T)
}
return this as T
}
public inline fun Any.castOrNull(): T? {
contract {
returnsNotNull() implies (this@castOrNull is T)
}
return this as? T
}
internal expect inline fun T.freeze(): T
public inline fun T?.ifNull(defaultValue: () -> T): T {
contract {
callsInPlace(defaultValue, InvocationKind.AT_MOST_ONCE)
}
return this ?: defaultValue()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy