The typical way of using forEach()
(things.forEach { println(it) }
) makes it
look like forEach()
is not a function. It is, but functions whose last parameter
is a lambda expression can have the expression appear outside the parentheses. And,
if there are no other parameters to the function, you can skip the parentheses
entirely. So, this snippet is the same as the previous one, just with
a more function-like syntax.
You can learn more about this in:
Tags: