mapIndexedNotNullTo

abstract fun <R : Any, C : MutableCollectionWrapper<in R>> mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C

将对原始可迭代对象中每个元素应用给定 transform 函数的结果添加到 destination 中, 并提供元素的索引,但仅包含不为 null 的结果。

Return

destination,以便链式调用。

Parameters

destination

用于存储结果的 MutableCollectionWrapper

transform

用于将每个元素转换为结果的函数,接收元素的索引和元素本身作为参数。