java.util.Optional fields

Remi Forax forax at
Sat Sep 22 09:39:32 PDT 2012

On 09/22/2012 06:16 PM, Sam Pullara wrote:
> One interesting thing to note is that it is usually rare to call isPresent on an Option in Scala is usually a code smell. I would think that the code would look more like:
> optional.forEach( o -> { if (o == null) throw; ... })
> I like Doug's proposal of having two forms, one that returns Optional and another that has a default value. Also, I prefer Guava's optional that doesn't have a public constructor so that:
> Optional.of(null) == Optional.empty()
> How impossible would it be to get better null behavior into the JVM? Is that on any future roadmap? If it was easy to ignore nulls like in Kotlin's Safe calls, this wouldn't really come up and would probably perform better:

Groovy or Phantom have the same operator, such operator was requested by 
the Java community during the development of the coin project but 
rejected, I don't remember why.

That's in my opinion the best argument against Optional which is we 
should provide a complete solution to deal with null and not a partial 
solution as Optional is.

> Sam


More information about the lambda-dev mailing list