Wednesday, September 30, 2015

Why UnaryOperator if it cannot be composed

UnaryOperator is the functional interface which input parameter and return parameter are the same type.

In functional programming, it often needs compose several functions together.
But when one UnaryOperator compose another UnaryOperator, it returns a Function, it will get compile error if the method expecting UnaryOperator as parameter.

So when declare a method, prefer to using Function as parameter type instead of UnaryOperator

No comments:

Post a Comment