# Hashes

Hashes are collections that save data as key-value pairs. This means that a key will identify every value that we want to save. This also means that keys within a hash have to be unique, otherwise we will overwrite the old values.

In terms of performance, hashes have a lookup time of **O(1)**, which means that finding a value in a hash by its key will not be dependent on the size of the hash, nor on the order in which the hash was created. **O(1)** means a constant lookup time for the operation performed on a hash, irrespective of the data size. This differs from arrays, where finding a value in an **O(n)** operation means that the time taken to find an element in an array will be dependent on the length of an array. This means that we are looking for an element and we are going to find it on the *nth* location; the **n** does not denote the size of the array, but the location of the element.

An empty hash can be created as follows:

my_hash = {} my_hash = Hash.new

The output will...