Optional -> OptionalResult

Zhong Yu zhong.j.yu at gmail.com
Wed Jun 5 09:23:32 PDT 2013

On Wed, Jun 5, 2013 at 5:47 AM, Stephen Colebourne <scolebourne at joda.org> wrote:
> On 5 June 2013 11:32, Mark Derricutt <mark at talios.com> wrote:
>> I don't want to nitpick, but Map<Option<List<Foo>>>  isn't even a valid type for Map<K,V>
> Thats why I use an IDE ;-)
>> However, if Map had a method that returned an Optional<V>  if the value from absent from the map, say Map#find, Map#getOptional or Map#getResult you could train developers into not putting Optionals directly in the map to start with.
>> Something like:
>>    String name = map.getResult("firstName").or("");
> I agree. In the return type position it works well. Given your
> proposed method is getResult(), it suggests that the returned class
> would make sense to be called Result<T>. Thats the real point of this
> thread.

Yes, can we agree on a small thing first, that "Optional" is a
nonsensical name for the class. Google "define optional"

Available to be chosen but not obligatory
Left to choice; not compulsory or automatic.
possible but not compulsory; left to personal choice
left to one's choice; not required or mandatory

- Jackets are required at the restaurant, but ties are optional.
- Many optional features are available on this car.
- Registration is optional, not mandatory.

The meaning of the word in plain English has nothing to do with the
contract of Stream.findFirst() etc.

More information about the lambda-dev mailing list