forEachIndexed

abstract fun forEachIndexed(action: (index: Int, T) -> Unit)

对此可迭代对象中的每个元素执行给定的 action,并提供元素的索引。

Parameters

action

要对每个元素执行的操作,接收元素的索引和元素本身作为参数。