Hash in Ruby

Learn how to use a hash in Ruby language.

We'll cover the following...

Defining hash in Ruby

To define a hash in a Ruby program, we need to use curly brackets. Remember that we use square brackets for arrays:

$ pry
> obj = {}
...
> obj.class
Hash < Object

We should not name the variable hash because it is a reserved language ...