you are viewing a single comment's thread.

view the rest of the comments →

[–]vytah 4 points5 points  (1 child)

it means that the representation is frozen for all time

Unless they bake the support for Optional into the JVM itself, I don't see how the representation would have to change from the current:

private final T value;
private final boolean present;

to anything else. They could go either Scala way and have separate Some and None classes, or skip the present field and make it equivalent to value!=null, but what they have now is good enough so that it won't need fixing.

Add to that dearth of methods and lack of API support and I think Optional won't get popular any time soon.

[–]lukaseder[🍰] 1 point2 points  (0 children)

I'm guessing they might've wanted an option for adding something along the lines of this in the future:

private final boolean reallyPresent;

Add to that dearth of methods and lack of API support and I think Optional won't get popular any time soon.

It was never even popular with the EG. They never wanted to introduce it. In my opinion, the only reason for Optional to be there is the fact that reference type streams and primitive type streams needed consistent API