Is there any reason why `Sequence<T>.drop(n:...
# stdlib
j
Is there any reason why
Sequence<T>.drop(n: Int)
param type is
Int
instead of
Long
? I thought Kotlin’s sequence is equivalent to Java’s stream, and presuming the type should be the same as
Stream<T> skip(long n);
In what aspect? From my understanding, they are all representing a possible infinite stream of data, and can do minimal & lazy calculations
Thanks for your explanation, but back to the question, I still get confused why it's an Int but not a Long, since it can represent an infinite flow
yeah, this makes sense. I just wonders if there’s some special thinkings behind when implementing this function
e
Sequence effectively wraps an Iterator, Stream effectively wraps a Spliterator, these are not the same
in particular, collections are expected to be representable in-memory and thus are explicitly limited to int sizes, which extends through iterators and sequences, while spliterators are generalized to larger and parallel streams
👍 4