Stream proposal and null results
Artur Biesiadowski
abies at adres.pl
Thu May 17 17:07:04 PDT 2012
On 18/05/2012 00:09, Brian Goetz wrote:
> Similarly, if we added an Option-bearing get-like method to Map (not
> saying we're going to do this), the same would be true:
>
> String s = map.getAsOption(key)
> .getOrElse(DEFAULT_STR);
>
String s = map.get(key) ?: DEFAULT_STR;
Is it worth to 'pollute' every API in existence just to avoid
introducing elvis operator? I think that we should accept that java has
null very much ingrained in the culture, adapt it as 'None' Option and
just add easy syntax to work with that. Garbage collector will be very
happy with that solution as well.
We could then have some kind of nullability indicator in type itself,
either as
@Nullable String s;
@NotNull String s;
or (just a wild idea, I know it won't fly)
String? s;
String! s;
to indicate Option-like results in the API.
Regards,
Artur Biesiadowski
More information about the lambda-dev
mailing list