how come i can't do list.forEach(println) and i have to do list.forEach(::println)?
m
Mike
12/31/2018, 2:28 PM
The first is calling a function, so you have to give it a parameter.
list.forEach(println(it))
will work.
The second is passing a function reference. The function (println) takes one parameter.
forEach takes a Lamda/function that accepts one parameter. So it is coded such that it calls the function with its parameter for you.
HTH