Pure functions and higher order functions
You don't have to remember most of the terms introduced in this chapter; the important thing is to understand how they help us write simplistic but powerful programs.
RxJava's approach has many functional ideas incorporated, so it is important for us to learn how to think in more functional ways in order to write better reactive applications.
Pure functions
A pure function is a function whose return value is only determined by its input, without observable side effects. If we call it with the same parameters n times, we are going to get the same result every single time. For example:
Predicate<Integer> even = (number) -> number % 2 == 0; int i = 50; while((i--) > 0) { System.out.println("Is five even? - " + even.test(5)); }
Each time, the even function returns False
because it depends only on its input, which is the same each time and is not even.
This property of pure functions is called idempotence. Idempotent functions...