News for hackers. Stuff that matters.
Re:Pattern Matching for Java by pvorb on Thursday April 20, 2017 @03:15AM (#14154589)
With Java 8 having Optional and Lambdas, this is no longer the case:

  final Optional<String> myOptionalVar = functionThatReturnsOptional();
  
  final String output = myOptionalVar
    .map(str -> str.length() > 10
      ? "This is a long string."
      : "This is a short string.")
    .orElse("This code would be fifteen lines of null checking in Java.");
  
  System.out.println(output);

There are no comments on this comment yet.