From the course: Complete Guide to Ruby

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Arrays

Arrays

- [Instructor] In this movie, we will learn about arrays, which are an important object type in Ruby, and a common feature of many programming languages. An array is an ordered, integer-indexed collection of objects. That's a fancy way of saying that we're going to put objects into an ordered list and then refer to them by their positions in that list. That's what integer-indexed means. We can request the first object, the fifth object, and so on. You can think of an array as being like an expanding file folder. You might store your electric bill in the first pocket and your phone bill in the second pocket and your car payment in the third pocket, and so on. There's a set order to the pockets and you can move papers in and out of those pockets. Some pockets can be empty, but that empty space in the order will be preserved. Unlike a file folder, though, arrays have an unlimited number of pockets. In Ruby, the count of the pockets, or positions in the array, starts with 0. We call them…

Contents