- Ruby
- Beginner
About this Course
In the Ruby Collections course at Treehouse, you'll level up your Ruby knowledge and start learning about collections. We use two basic data structures to create collections in Ruby: arrays and hashes. These are both examples of "collections" and you’ll work with them a lot in your career as a Ruby programmer. During the course, we'll be writing simple programs that build on what we learned in this course and in previous courses.
What you'll learn
- Ruby Arrays
- Ruby Hashes
- Ruby Collections
Ruby Arrays
An array is a container of data, similar to a list. Arrays can be used to store many different kinds of data including strings, numbers, and almost any other kind of Ruby object. In this stage, we'll learn how to create and manipulate arrays.
8 stepsRuby Hashes
A hash is data structure similar to an array. Hashes are used all throughout Ruby programs. In this stage, we'll get comfortable creating and working with hashes in Ruby.
8 stepsBuild a Grocery List Program
Now that we know how to use arrays and hashes, we're going to build a small program that makes a grocery list for us. We'll combine all of the knowledge we've learned so far including input and output, method definitions, and more.
9 steps-
Build a Grocery List Program: Part 1
3:15
-
Create a Method That Returns a Hash
1 objective
-
Build a Grocery List Program: Part 2
3:58
-
Create a Method That Returns an Array
1 objective
-
Build a Grocery List Program: Part 3
3:47
-
Method Returns with Hashes and Arrays
1 objective
-
Build a Grocery List Program: Part 4
4:17
-
Working with Hashes That Contain Arrays
1 objective
-
Ruby Collections: Review
6 questions
-
Extra Credit
On your own, research how to use loops and modify our grocery list program to continually ask for input rather than only ask for three different items.
Teacher
-
Jason Seifer
Jason helped launch Treehouse and spent 4 years teaching here before returning to Rails development full time.