The sequence needs to be iterated once just to get...
# announcements
p
The sequence needs to be iterated once just to get the size, and some sequences can't be iterated multiple times, so it'd have to store off the items in some temporary collection anyway. Probably best if that's just explicit for the caller.
🙇‍♂️ 1
h
But isn't that the same when calling
.toList()
? They also have to add to the
ArrayList
all the sequence's elements – copying the array when they run out of space and all. IMO they could've just added something like
inline fun <reified T> Sequence<T>.toTypedArray(): Array<T> = this.toList().toTypedArray()
and be done with it.