Time value key : Hash Keys « Hash « Ruby






Time value key



require 'time'
click_counts = {}
1.upto(30) { |i| click_counts[Time.parse("2006-09-#{i}")] = 400 + rand(700) }
p click_counts

 








Related examples in the same category

1.Return an array containing all the keys in a hash with keys:
2.Extract data from the hash by using its keys.
3.Use number as hash key
4.Retrieving Keys
5.Join hash keys together
6.RuntimeError: hash modified during iteration
7.Get all keys from a hash
8.Searching a Hash with Regular Expressions
9.What if a key does not exist
10.Hash as a key