forEach

public inline fun <T> Iterable<T>.forEach(action: (T) -> Unit): Unit {
    for (element in this) action(element)
}

val list = listOf(1, 2, 3, 4, 5)
list.forEach{ println(it) }  // 1 2 3 4 5

Last updated