5. Collections and Iterations

Collections form an important part of almost any object-oriented programming language. They let us easily store multiple values either in a list, such as an array, or using a key/value pair, like objects in JavaScript. With objects we can represent an item, such as a book, and give it values such as a title, author, and publication date. Using an array we can then store a list of the book objects we create.

Along with collections come iterators. Iterators let us take our stored values, such as that list of books, and loop through them one at a time, allowing us to print each one to the screen, update some information on each book, or do whatever our application needs to do.

In the first half of this chapter we learn ...

Get Programming in CoffeeScript 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.