I understand that a lambda in java cannot throw a checked exception, but can throw a RuntimeException, but why does the below code require brackets?
Map<String, Integer> m = new HashMap<>();
Integer integer = m.computeIfAbsent("", s -> {throw new IllegalArgumentException("fail");});
Why can't you have?
m.computeIfAbsent("", s -> throw new IllegalArgumentException("fail"));
Is it due to the assumption of the compiler that it would return in this instance an int, so therefor can't have a return of an exception, even though its thrown?