much better return type for Iterable.sequence()
See original GitHub issueToday, @jvasileff figured out the solution to a problem that has bugged us for years — how to assign the correct return type to Iterable.sequence()
for known-nonempty streams.
The return type is:
[Element+] | []&Iterable<Element,Absent>
There would be one big problem with making this change, and one much smaller problem:
- It would involve a binary-incompatible change to the return type of
Iterable.sequence()
, which at the Java level would widen fromSequential<? extends Element>
toObject
. - For the case of an empty stream, that is not something special like
[]
,""
, or{}
, callingsequence()
would result in a reified check of the type argumentAbsent
.
Problem (1) is rather easy to fix with a little hack to the compiler backend to preserve the previous return type Sequential<? extends Element>
.
Problem (2) is not so easy to fix, but may not be a big deal.
Issue Analytics
- State:
- Created 7 years ago
- Comments:27 (27 by maintainers)
Top Results From Across the Web
How can i return Iterable with a Function? - Stack Overflow
Implement the Iterator interface by providing implementations for next() and hasNext() . hasNext() simply returns true or false if you have ...
Read more >Incremental Transformation of an Iterable Sequence in Java
The main class implements the Iterable interface (an abstract factory of iterators). The factory method ( iterator() ) returns a new RIterator ,...
Read more >Python Basics: Iteration, Iterables, Iterators, and Looping
An iterable is an object capable of returning its members one by one. Said in other words, ... Sequences are a very common...
Read more >Should I return Iterable or Enumeration in Java
In order to achieve better immutability, should my API return java.lang.Iterable<T> or java.util.Enumeration<E> ? Since Iterable's iterator has a remove() ...
Read more >Iterables - Python Like You Mean It
all : returns True only if bool(item) was True for all items in the iterable. max : return the largest value in an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Type functions FTW.
Amazing, great!