how come i can't do list.forEach(println) and i ha...
# getting-started
j
how come i can't do list.forEach(println) and i have to do list.forEach(::println)?
m
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