Iterators

Get introduced to iterators, which are another major cornerstone of functional programming.

We'll cover the following

Iterators

An iterator is a trait that allows us to perform the same task over a collection of elements in turn. Iterators are lazy.

The canonical definition of an iterator takes the form of the .iter() method on iterables. However, the simplest use of an iterator is through the method .next().

There are many more methods and higher-order functions for the use of iterators. There are also some well-known iterables we should learn.

Let’s look at an example:

Get hands-on with 1400+ tech skills courses.