I don´t understand why in some cases the Consumer function ignores the return type returned from the function and in other cases not.
Code: Select all
Consumer<Book> c = b->b.getId()+":"+b.getTitle();// this doesn´t compile, the type of the expression must be void, here is a String.
Code: Select all
Consumer<Book> c = b->b.getTitle();// but here compiles, the type of the expression is String as the previous one.
Thank you in advance