Loose ends: Optional

Sam Pullara spullara at gmail.com
Mon Jun 3 18:28:21 PDT 2013


There are a few things that I think are useful that are in Fugue and/or Scala:

- ofNullable that returns Empty if it is null — I would prefer that be the behavior of of(). Also, since this will likely be statically imported, i would name it something like option() or optional() instead of of()
- boolean exists(Predicate<A> predicate) — returns true if it exists and satisfies the predicate. it can be emulated, but this is a nice convenience method.
- a version of orElse that takes and returns an Optional

Sam

On Jun 3, 2013, at 5:44 PM, Joe Bowbeer <joe.bowbeer at gmail.com> wrote:

> Fugue's Option adds the controversial methods that are missing from Guava's Optional:
> 
> From bitbucket.org/atlassian/fugue
> 
> "This library attempts round out some of the deficiencies that a functional programmer finds when using Guava. In particular it provides Option and Either types similar to the Scala library as well as a Pair."
> 
> The lambda-dev post that Brian referenced in earlier in this thread was written by Jed Wesley-Smith, who has committed most of Fugue's code.
> 
> --Joe
> 
> 
> On Mon, Jun 3, 2013 at 5:32 PM, Mike Duigou <mike.duigou at oracle.com> wrote:
> 
> On Jun 3 2013, at 10:03 , Joe Bowbeer wrote:
> > Does everyone agree that Fugue's Option is an improvement on Guava's
> > Optional?
> 
> How is Fugue's Optional an improvement? I guess I am pretty satisfied with Brian's proposal for java.util.Optional and would be similarly satisfied with the Guava Optional. If there are benefits to Fugue or other's Optional beyond implementation details I would like to understand what they are believed to be.
> 
> Mike
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/lambda-libs-spec-experts/attachments/20130603/c26af43a/attachment.html 


More information about the lambda-libs-spec-experts mailing list