Primitive streams and optional (original) (raw)
Remi Forax forax at univ-mlv.fr
Sat Nov 24 14:28:10 PST 2012
- Previous message: Primitive streams and optional
- Next message: Primitive streams and optional
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 11/24/2012 10:41 PM, Brian Goetz wrote:
Also, what's the corresponding proposal for primitive streams? I would hate to force boxing onto users of:
Integer x = intStream.filter(...).findFirst(); just because we don't have an int sentinal we can use.
the main issue with this code is that people can write int x = intStream.filter(...).findFirst();
a will get a NPE without knowing why.
If we're going to do this to people, we might as well give them a null-safe box (OptionalInt) rather than an accident waiting to happen.
I prefer int x = intStream.filter(...).findFirst(() -> 0); or int x = intStream.filter(...).findFirst(() -> throw new WeAreInTroubleException());
Rémi
- Previous message: Primitive streams and optional
- Next message: Primitive streams and optional
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-observers mailing list