
commonMain.com.tweener.kmpkit.contract.Preconditions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kmpkit Show documentation
Show all versions of kmpkit Show documentation
A Kotlin Multiplatform utility library offering extensions, validators, providers, coroutine tools, and more to enhance KMP development.
package com.tweener.kmpkit.contract
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
/**
* @author Vivien Mahe
* @since 17/12/2024
*/
@OptIn(ExperimentalContracts::class)
inline fun requireNotNullOrThrow(value: T?, throwable: () -> Throwable): T {
contract {
returns() implies (value != null)
}
if (value == null) {
throw throwable()
} else {
return value
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy