DkIterableEachExt<E> extension

可迭代对象遍历功能扩展

on

Methods

forEachIndexed(void action(int index, E element)) → void

Available on Iterable<E>, provided by the DkIterableEachExt extension

带索引的遍历
mapIndexed<U>(U toElement(int index, E element)) Iterable<U>

Available on Iterable<E>, provided by the DkIterableEachExt extension

类似 map,但是有当前元素的索引。
onEach(void action(E element)) Iterable<E>

Available on Iterable<E>, provided by the DkIterableEachExt extension

action 应用于每个元素,返回整个未修改的 Iterable
onEachIndexed(void action(int index, E element)) Iterable<E>

Available on Iterable<E>, provided by the DkIterableEachExt extension

action 应用于每个元素,返回整个未修改的 Iterableaction 第二个参数 index 是元素索引位置。
sum(num addend(E element)) num

Available on Iterable<E>, provided by the DkIterableEachExt extension

根据定义 addend 返回 this 中所有值的总和。