Is it recommended to write contracts for my functi...
# announcements
j
Is it recommended to write contracts for my functions? I want to have this function
Copy code
inline fun measureTimeMillisWithContract(block: () -> Unit): Long {
    contract {
        callsInPlace(block, EXACTLY_ONCE)
    }
    val start = System.currentTimeMillis()
    block()
    return System.currentTimeMillis() - start
}
but as it requires me to add the
@ExperimentalContracts
annotation, I don't really feel good to use contracts.
n
it is weird the built-in
measureTimeMillis
doesn't have this already
j
I found an issue for it on youtrack, they didn't want to change it for compatability policy. But I think it's in Kotlin 1.4 https://youtrack.jetbrains.com/issue/KT-27856
i
it is weird the built-in measureTimeMillis doesn't have this already
Does have it already: https://kotlinlang.slack.com/archives/C0922A726/p1597687744182700