In today’s episode of Kotlin Standard Library Safari, we’re learning all about advanced collection functionality!

We’ll see how the ‘any’, ‘none’, and ‘all’ functions can be used to check conditions for elements in our collections, and tease our brains with empty collections and the concept of the vacuous truth.

We will then learn different ways of breaking collections into parts, both by creating chunks from our collection elements, and obtaining a sliding window view of our items. In the process, we’ll also discover how we can directly apply transformations to the resulting collections by passing lambdas to the chunked and windowed functions from the Kotlin standard library.

With flatten and flatMap, we’ll be introduced to convenient ways of turning nested collections, like lists of lists, back into collections of plain elements.

Equipped with the ‘zip’, ‘unzip’, and ‘zipWithNext’ functions, we’ll try our hand at working with multiple, related collections before wrapping up with the powerful ‘fold’ and ‘reduce’ functions, which we’ll use to create our own aggregations over collections.

#kotlin

Advanced Collection Operations
1.65 GEEK