I have a function in kotlin
fun printExecutionTime(block: () -> Any) {
run {
val currentTimeMillis = System.currentTimeMillis()
block()
Logr.d("Execution time of " + block.javaClass.name + " -> " + System.currentTimeMillis().minus(currentTimeMillis))
}
}
In java code, I want to pass void reference function as parameter, but can't bcs of return value
PerformanceKt.printExecutionTime(this::voidFunc);
One way will be to use interface
interface Action {
fun call()
}
Is it possible to declare it in kotlin without an extra interface, so the code above will work?