tim at peierls.net
Sat Sep 22 06:37:21 PDT 2012
On Sat, Sep 22, 2012 at 8:00 AM, Doug Lea <dl at cs.oswego.edu> wrote:
> 1. Stream operations ignore null elements.
> 2. Each operation that can return a "nothing there" result has two forms
> Optional<T> op(...)
> T op(..., T defaultValueIfNone);
Yup, that does feel like the sweet spot. In my perfect world, (1) would
never apply and the second form in (2) would turn out not to have been
necessary. But that's unrealistic on both counts.
> (And enables the spec for Optional to say that a present
> optional is never null.)
Yes, very desirable.
> My guess is that once some of the
> newness of fluency wears off, most people will be in the
> second group, so will want multiple options.
Both forms are "fluent", at least the way I think of fluency. But it's not
too terrible having both options, and as Doug points out, the second form
handles the null case nicely.
More information about the lambda-libs-spec-observers