O'Reilly logo

Programming in CoffeeScript by Mark Bates

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required