for Each
Performs the given action on each element.
inline fun <K, V> Map<out K, V>.forEach(action: (Map.Entry<K, V>) -> Unit)
Content copied to clipboard
Performs the given action on each entry.
Performs the given action on each element.
Since Kotlin
1.3
Performs the given operation on each element of this Iterator.
Samples
import samples.*
import java.util.*
fun main() {
//sampleStart
val iterator = (1..3).iterator()
// skip an element
if (iterator.hasNext()) {
iterator.next()
}
// do something with the rest of elements
iterator.forEach {
println("The element is $it")
}
//sampleEnd
}