I'd like to use a contract to ensure that a Pair&l...
# getting-started
b
I'd like to use a contract to ensure that a Pair<K?, V> is treated as Pair<K, V>, but I can't get this to work
Copy code
@OptIn(ExperimentalContracts::class)
internal fun <K, V> hasNonNullFirst(pair: Pair<K?, V>): Boolean {
    contract {
        returns(true) implies (pair is Pair<K, V>)
    }
    return pair.first != null
}
1
d
b
thank you!