Archives: orElse versus orElseGet misuse

Java8 orElse versus orElseGet – easily misused

So, the Java8 Optional has two really cool (and similar) functions: the orElse() and the orElseGet(). If we quickly read the javadoc for each, we will only see a small difference; one of them has a T type as a parameter and the other has a function which must return with T (as a parameter). […]