Before Ruby 1.9.1p0
Key and Value are separated by => that means name => value
day_selection = {
'day1' => 'monday',
'day2' => 'tuesday',
'day3' => 'wednesday',
'day4' => 'thursday',
'day5' => 'friday',
'day6' => 'saturday',
'day7' => 'sunday'
}
p day_selection['day1']
In Ruby 1.9.1p0
Key and Value are separated by: that means name: value
day_selection = {
day1: 'monday',
day2: 'tuesday',
day3: 'wednesday',
day4: 'thursday',
day5: 'friday',
day6: 'saturday',
day7: 'sunday'
}
p day_selection[:day1]
Note: Remove single quote from the name
Hashes
In Ruby 1.9.1p0
Ruby remembers the order in which we are add items to a hash. When we will iterate over the entries, Ruby will return them in that order.
