Teeing Operations
In almost all the examples we’ve seen in this chapter, we converted a collection into either a single value or another collection. The only exception to this so far was the partitioningBy function that produced two separate collections. That’s powerful but limited to giving us a collection that satisfies a given criteria and another that doesn’t. What if we want to take this idea of producing two different results from one iteration, but the results aren’t directly related to each other or mutually exclusive.
The teeing function creates a Collector that will apply two different transformations on the data that flows through and finally merges the two results into one cumulative result.
Suppose we want to get the full name of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access