forEach
inline fun ByteArray.forEach(action: (Byte) -> Unit)
inline fun ShortArray.forEach(action: (Short) -> Unit)
inline fun IntArray.forEach(action: (Int) -> Unit)
inline fun LongArray.forEach(action: (Long) -> Unit)
inline fun FloatArray.forEach(action: (Float) -> Unit)
inline fun DoubleArray.forEach(action: (Double) -> Unit)
inline fun BooleanArray.forEach(action: (Boolean) -> Unit)
inline fun CharArray.forEach(action: (Char) -> Unit)
inline fun <T> Iterable<T>.forEach(action: (T) -> Unit)
@ExperimentalUnsignedTypes inline fun ULongArray.forEach(
action: (ULong) -> Unit)
@ExperimentalUnsignedTypes inline fun UByteArray.forEach(
action: (UByte) -> Unit)
@ExperimentalUnsignedTypes inline fun UShortArray.forEach(
action: (UShort) -> Unit)
Performs the given action on each element.
Performs the given action on each entry.
inline fun <T> Iterator<T>.forEach(operation: (T) -> Unit)
Performs the given operation on each element of this Iterator.
import java.util.*
fun main(args: Array<String>) {
//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
}