great article, just one small correction: You state that
null
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
Copy code
val foo = null
println(::foo)
n
nfrankel
09/10/2019, 5:46 AM
thanks!
but i’m not the author 😅
b
bdawg.io
09/11/2019, 9:18 PM
Another thing I noticed is in this snippet:
Copy code
//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