All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.tweener.kmpkit.contract.Preconditions.kt Maven / Gradle / Ivy

Go to download

A Kotlin Multiplatform utility library offering extensions, validators, providers, coroutine tools, and more to enhance KMP development.

There is a newer version: 1.0.5
Show newest version
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