And Ilya Grigorik had an interesting post with some other nice Ruby fu’s.
]]>1 | h = Hash.new([]) |
Wow, it looks much better. Thank you!
]]>1 2 3 4 5 6 | a = %w(apple banana apple) h = Hash.new { [] } a.each_with_index do |fruit, i| h[fruit] <<= i end puts h.inspect |