Could anyone explain the result of following code snippet? Why the first function call returns kotlin.Unit?
kotlin version 1.5.21, java11
fun <T> testMethod(data: String?): T? = data?.let { return null }
println(testMethod<String>(null)) // --> kotlin.Unit
fun <T> testMethod2(data: String?): T? = data?.let { null }
println(testMethod2<String>(null)) // --> null
Why the result is different in kotlin 1.4.30 - https://pl.kotl.in/uFZDE3O9e?