if the key or value doesn't exist, accessing the hash will return the default value: months = Hash.new( "month" ) months[0] # or: months[72] # or: months[234]