Hashes

  • By default the value returned for nonexistent keys is nil
myHash = {'one' => 'alpha', 'two' => 'beta'}
myHash['three'] = 'gamma'

myHash = Hash.new(0) # Return 0 for nonexistent keys

myHash.length