Search⌘ K
AI Features

Introduction to Internal Iteration and Lazy Evaluation

Discover the concept of internal iteration in Kotlin and how it differs from external iteration. Learn to use higher-order functions with lambdas to process collections effectively. Understand the role of lazy evaluation with sequences to enhance performance, especially with large data sets, helping you write concise and efficient Kotlin code.

We'll cover the following...

Unlike the imperative style where external iterators are prominent (see Chapter 5, External Iteration and Argument Matching), in functional programming we use internal iterators. Internal iterators put iterations on autopilot; instead of focusing on iteration, you can keep your eyes on what to do for each element in a collection or a range. As well, internal iterators avoid explicit mutability ...