Optional != @Nullable

Artur Biesiadowski abies at adres.pl
Sun Sep 30 01:36:21 PDT 2012

On 30/09/2012 10:13, Jed Wesley-Smith wrote:
> Option<String> address(Session session) {
>    return optional(
>      session.getIoSession().getRemoteAddress()
>    ).flatMap(socketAddress -> optional(socketAddress.getAddress())
>    ).flatMap(inetAddress -> optional(inetAddress.getHostAddress()));
> }

Is it really more readable than

return session.getIoSession().getRemoteAddress().?getAddress().?getHostAddress();


Given java history and existing libraries, I think that repurposing null 
as None, assuming non-null contents of collections for most of 
lambda-empowered libraries/utilities and providing few operators for 
safe traversal (?. and ?: at least) would be a lot more useful solution.

Artur Biesiadowski

More information about the lambda-dev mailing list