You've heard the phrase “diamonds are a girl's best friend”? Well, rubies are a nerd's best friend, and in this tutorial I am going to show you why. We'll discuss operators, conditionals, loops, hashes, and arrays in Ruby. And that's not all.
If you want to work with words instead of numbers for you indices, hashes is the way to go. Let's say you want to make a list of people's weight and print out a person from the list at random, to humiliate them throughout the day. For this, we could use Hashes, which remind me of hash browns and make me very hungry.
Hashes are also referred to as associative arrays. And unlike arrays that use [] brackets, hashes use the curly braces {}.
Instead of index numbers, in Hashes we use hash keys. In the above instance, James is a hash key and 400 is the value you associate with that key. So let's say I want to embarrass that fatty James (I'm said fatty by the way), we would use the following code, then call everyone over to look at it, making sure to point and slap the cheeseburger out of his (my) hand.