Lambda 'special void-compatibility rule' - statement expression
问题 Im reading Java 8 in Action. In section 3.5.2 there is a paragraph about 'void-compatibility rule': If a lambda has a statement expression as its body, it’s compatible with a function descriptor that returns void (provided the parameter list is compatible too). For example, both of the following lines are legal even though the method add of a List returns a boolean and not void as expected in the Consumer context (T -> void): // Predicate has a boolean return Predicate<String> p = s -> list