nfrankel
09/09/2019, 5:12 PMBurkhard
09/10/2019, 3:10 AMnull
has no type, but it’s type is Nothing?
. You mention that later by saying that Nothing?
as a return type forces you to return null
. You can also verify this with this code
val foo = null
println(::foo)
nfrankel
09/10/2019, 5:46 AMbdawg.io
09/11/2019, 9:18 PM//Java
public static Consumer<Integer> printNum = x -> System.out.println("Num " + x);
//Kotlin
fun callMe(block: (Int) -> Unit): Unit = (1..100).forEach(block)
fun main(){
callMe { Lambdas.printNum } //it works fine
}
nothing would happen because he's not actually passing in the function (and as far as I understand it won't compile). I believe the following was actually meant callMe(Lambdas::printNum) // it works fine