Working with Ruby Arrays

Hi there!

Most of the time, we’ll be working with collections of things. In Ruby, these collections are called arrays. Today we’ll be working with arrays and perform some basic operations to help everyone get started. Don’t worry! It’s not that hard to work with Ruby arrays.

I’ll provide a simple example of this powerful tool by marrying one of the things I love the most – Japanese cuisine. We’ll create our own chirashi. It’s basically a big bowl of rice with various ingredients.

On this chirashi, we’ll add the following ingredients: Uni (Sea Urchin), Maguro (Tuna) and Hamachi (Pacific Yellowtail).

Screen Shot 2016-01-01 at 11.50.39 PM


Step # 1: Create an array (or the chirashi) with 3 elements (or ingredients). Take note that “Uni” is at index 0, “Maguro” is at index 1, and “Hamachi” is at index 2. If this confuses you, just remember that counting starts at zero in Ruby arrays.

chirashi = [“Uni”, “Maguro”, “Hamachi”]


Step # 2: What is the first element that we added to the array? To print the first element of the array, you can access it by adding [0] to the name of the array since “Uni” is at index 0

puts chirashi[0]

=> Uni


Step # 3: Print the second element of the array. Since “Maguro” is at index 1, you can access it by adding [1] to the name of the array

puts chirashi[1]

=> Maguro


Step # 4: Oh, I changed my mind. I wanted to add Tamago (Egg) too. In this case, if we wanted to add another item to the array, we can use push to append the new element.


=> [“Uni”, “Maguro”, “Hamachi”, “Tamago”]


Step # 5: What was the latest item we added into the array again? To print the fourth element of the array, remember that the index is 3 for the fourth item as seen below.

puts chirashi[3]

=> Tamago


It’s that easy! Most of the time, we’ll just be creating arrays and appending to existing ones so this should help you get started.

Stay tuned for more!

(315) 427-7261

Hi Everyone!

Before we delve into the world of coding any further, I thought it was crucial to spruce our terminal up a bit since we’ll be using it for some time. From our previous post, you can see that the terminal looked bland and boring. This post will help us change the look and feel of the terminal to something cooler like this:


Step # 1: The first step is to go to Terminal > Preferences.

Screen Shot 2016-01-01 at 9.52.23 PM

Step # 2: Go to Profiles and simply select the theme you want. I chose “Homebrew”. Then, click the Default button afterwards.

Screen Shot 2016-01-01 at 9.52.42 PM

Step # 3: Voila!

Screen Shot 2016-01-01 at 9.47.37 PM

Doesn’t it look so awesome?

Stay tuned for more updates!

(618) 973-6901

We’re all hyped up and ready to just start coding. You’ve waited all your life and the moment is finally here. You’ll definitely be the next Bill Gates of this generation. Then, a brick wall just appears out of nowhere – the Terminal. Many people are afraid of using the terminal but do not worry! It’s just a place where you type in the commands.

The Terminal
The Terminal

You have no clue what those symbols are and the fat blinking cursor doesn’t help at all. I’ve clicked that exit more times that you could imagine. It’s too foreign and you simply can’t deal with this unfamiliar madness.

You have to start somewhere though. It doesn’t have to be as grand as creating a website out of nowhere in a blink of an eye nor does it have to be perfect. It could be as simple as learning how to print a short string such as “Hello World” using Ruby and that’s what we’re going to do today.

Here are the step-by-step instructions on how to print a simple set of strings using Ruby:

1. Open your Terminal by using ‘Search’ on your Mac

2. Type ‘irb‘ without the quotes then press ENTER

3. Type ‘puts “Hello World”‘ then press ENTER

… and there you have it!

We just typed irb to run the Interactive Ruby Shell. Here we can run our Ruby scripts such as printing Hello World. It is that easy to get started with Ruby!

Stay tuned for more tutorials!

Sophie Learns to Code

Hi there! I’m Sophie and I’m learning how to code.

I’m pretty much like majority of the population on Earth. I presume a lot of people are super interested to learn code but have seemingly zero time and no formal training at all. It might seem too daunting at first but it’s not impossible. I mean who wouldn’t be?

I’ve learned quite a few nifty tricks the past couple of weeks and I can’t wait to share it to everyone. We’ll go through each and every tool step-by-step (and leave the boring parts to long inundated technical books). I promise to make it concise and relevant because ain’t nobody got time for dreary tutorials.

Wait for my next post in a couple of days!