Skip to content

Instantly share code, notes, and snippets.

Avatar

Jarno Walgemoed jwalgemoed

View GitHub Profile
View usage2.kt
fun printUserDetails(user: User?) {
if(user.isComplete()) {
println("${user!!.name} ${user!!.email}")
}
}
View use.kt
fun printUserDetails(user: User?) {
if(user?.isValid()) {
println("${user.name} ${user.email}")
}
}
View measuretimeContract.kt
@ExperimentalContracts
fun main(args: Array<String>) {
var assign: String
val time = measureTimeMillis {
assign = "Value Assigned"
}
println("$time ms. spent assigning: '$assign'")
}
@ExperimentalContracts
View measuretime.kt
fun main(args: Array<String>) {
var assign: String
val time = measureTimeMillis {
assign = "Value Assigned"
}
println("$time ms. spent assigning: '$assign!!'")
}
private inline fun measureTimeMillis(block: () -> Unit): Long {
val start = System.currentTimeMillis()