While reading the book i stumbled upon the following line: (Chapter 15, E-Book-Paragraph 2268-2269)
Moving on to Consumer, let's take a look at the andThen() method, which runs two functional interfaces in sequence.
... (code example)...
Notice how the same parameter gets passed to both c1 and c2. This shows that the Consumer instances are run in sequence and are independent of each other. By contrast, the compose() method on Function chains functional interfaces. However, it passes along the output of one to the input of another.
This passage lets me as reader assume that "andThen()" called on Function works exactly like in Consumer, which neither would make sense (as the original return value of the Function would be lost) nor is true. As expected from naming it chains the operations, just the other way around then compose().
Example: (extendet from example within the Book)
I assume, that the last phrase of the paragraph
However, it passes along the output of one to the input of another.
should point this behavior out.
May it would be more clear, when using following text:
Moving on to Consumer, let's take a look at the andThen() method, which runs two functional interfaces in sequence.
... (code example)...
Notice how the same parameter gets passed to both c1 and c2. This shows that the Consumer instances are run in sequence and are independent of each other. By contrast, the andThen() method on Function chains functional interfaces, As it passes along the output of one to the input of another. The Function's additional compose() method provides also chaining but in reverse order.
And know i ask myself why compose not just was named andBefore()?
Regards
Samuel Silver Moos