Why are functions like `.sumBy()` not defined on `...
# announcements
p
Why are functions like
.sumBy()
not defined on
kotlin.collections.Iterator<T>
too? I'm using android-ktx
fun <T> androidx.collection.SparseArrayCompat<T>.valueIterator(): kotlin.collections.Iterator<T>
and would like to sum the values. As a workaround I can call
toSequence().sumBy { it }
k
Because that's exactly what a sequence is: a wrapper around an iterator.
Adding extra overloads for iterators would be confusing: would it be eager (like iterable) or lazy (like sequences)?