Discussion: Introduce a Stream.reject
method, the opposite of Stream.filter
(original) (raw)
Paul Sandoz paul.sandoz at oracle.com
Fri May 18 18:39:45 UTC 2018
- Previous message: Discussion: Introduce a `Stream.reject` method, the opposite of `Stream.filter`
- Next message: Easy and safe cloning of methods, constructors, fields and parameters.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Jason,
One of the rationals for adding “Predicate.not" is to avoid adding another stream operation, such as “reject" or “filterNot", and instead one can use "filter(not(String::isEmpty))” rather than “filter(s -> !s.isEmpty())” if so desired. (This was the reason why i did not close down the issue, and sat on it, and thankfully Jim took action.)
We are trying to avoid adding “overloaded" forms of the same kind of operation, such as in this case, or filtering classes, or filtering values etc.
Hth, Paul.
On May 18, 2018, at 11:22 AM, Jacob Glickman <jhg023 at bucknell.edu> wrote:
Seeing as
Predicate.not
was just proposed, I think it would be a good idea to also introduceStream.reject
, which would be logically equivalent to callingStream.filter
with a negatedPredicate
, but with fewer method calls. Instead of: Stream.of("", "A", "B", "C") .filter(s -> !s.isEmpty()) .count(); You could call: Stream.of("", "A", "B", "C") .reject(String::isEmpty) .count(); I welcome any suggestions for better names other thanreject
. If this suggestion is supported, then I'll happily submit an RFE and the code, tests, etc. - Jacob
- Previous message: Discussion: Introduce a `Stream.reject` method, the opposite of `Stream.filter`
- Next message: Easy and safe cloning of methods, constructors, fields and parameters.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]