Kotlin collections have a forEach() function that lets you iterate over the collection members, invoking a lambda expression for each.

For Array, List, and Set, the lambda expression takes a single parameter. The lambda expression for forEach() on a Map takes two parameters: the key and the associated value.

You can learn more about this in:
Run Expand Edit