Comment

Comment by lkitching

Since this defines an interface, does this solve the null problem? e.g.

    Maybe<String> foo = null;
    foo.map(s -> "bar");
explicit pattern matching is usually discouraged anyway though, and you can do this now with Optional

    Optional<String> foo = Optional.empty();
    String message = foo.map(s -> "Hello " + s).orElse("Fine, leave me hanging");
Other languages like Scala also have an Option.fold method for this specific case.
parent lkitching 3 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton