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? - " ...

Get Learning Reactive Programming with Java 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.