forEachIndexed

inline fun <T> DataColumn<T>.forEachIndexed(action: (Int, T) -> Unit)

Calls action for every value of this DataColumn and its position, from the first value to the last one.

The position of the first value is 0.

This function returns Unit, so it is only useful for its side effects, such as printing values or collecting them. To get a new DataColumn of computed values instead, use mapIndexed.

For more information: See forEach on a DataColumn on the documentation website.

See also forEach — the same, without the positions.

Example

// Prints the first names, numbered:
// "1. Alice", "2. Bob", ...
df.name.firstName.forEachIndexed { i, firstName ->
println("${i + 1}. $firstName")
}

Parameters

action

A function that is called with the position of every value of this column and that value.