re: Is there such thing as a bad programming language? VIEW POST

VIEW PARENT COMMENT VIEW FULL DISCUSSION
 

This is why Java 8 introduced Optionals. It's not syntactic sugar so it's more verbose than the Kotlin example, but it does the same thing:

String manager = Optional.ofNullable(employee)
                         .map(Employee::getDepartment)
                         .map(Department::getHead)
                         .map(Person::getName)
                         .orElse(null);
 

Oh nice! I clearly haven't used Java in a while; I do still think the elvis operator looks a bit cleaner though.

Oh man... now I cannot unsee Elvis in the "Elvis operator" :-D

code of conduct - report abuse