forEach (original) (raw)

Performs the given action on each element.

Since Kotlin

1.0


Performs the given action on each entry.

Since Kotlin

1.0


Performs the given action on each element.

Since Kotlin

1.3


Performs the given operation on each element of this Iterator.

Since Kotlin

1.0

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
}