I get that ifPresent is already available; I'm curious if you examined how often there is actually an "if absent" case in practice, relative to the "only do something if present" case. If you don't have statistics, I could fairly easily get statistics on Google's codebase for what usages of Guava's Optional look like, in terms of how often if (optional.isPresent()) { ... } else { ... } occurs, relative to if (optional.isPresent()) { ... } // no else On Thu Feb 12 2015 at 10:15:45 AM Paul Sandoz <paul.sandoz@oracle.com> wrote:
On Feb 12, 2015, at 7:00 PM, Louis Wasserman <lowasser@google.com> wrote:
How often does the case when you "have a lambda handy already" come up in practice? If this leads to people using this method instead of ifPresent, that seems wasteful.
A lambda bearing ifPresent is already "present" (sorry!) :-) this is just filling it out to be consistent for a terminal operation with an empty action.
Guava's Optional succeeded as much for what it left out as what it had in -- I confess this makes me nervous that j.u.Optional is becoming a kitchen sink.
Yes, i most definitely share this concern. I have already closed a few optional issues as will not fix. FWIW I don't plan on adding any more stuff.
Paul.