Casting Spliterator<T> and methods signature
Boaz Nahum
boaznahum at gmail.com
Mon Apr 15 07:32:06 PDT 2013
Spliterator *interface *is source-only of elements, So Intuitively and
formally it can shown that it is safe casting Spliterator<? extends T> to
Spliterator<T>.
So, isn't better that methods that accept Spliterator<T> will accept
Spliterator<? extends T> :
public static <T> Stream<T> stream(Spliterator<? extends T> p1)
This makes user code much cleaner.
Thanks
Boaz
More information about the lambda-dev
mailing list