I am new learner for Java 8 lambda . I found a statement in a book (Java 8 for Really Impatient ), saying , "It is illegal for a lambda expression to return a value in some branches but not in others. For example, (int x) -> { if (x >= 0) return 1; } is invalid."
Can anyone explain this ? Please provide some examples.
Thanks in advance.
x) the expression is not returning anything - which is not allowed.