Great idea.

I were just experimenting, when I discovered a glitch in 
my understanding of Ruby..

What is the difference between 'Enumerable1' and 'Enumerable'.
Why does the 'Enumerable' work and the other not ???

Please enligthen me :-)


module Enumerable1
  def collect_by
    h = Hash.new []
    each{|i| h[yield(i)].push i}
    h
  end
end

module Enumerable
  def collect_by
    h = {}
    each{|i| (h[yield(i)] ||= []) << i}
    h
  end
end

a = (1..10).to_a
p a.collect_by {|i| i % 2}

# Enumerable1
#=> {}  
# Enumerable
#=> {0=>[2, 4, 6, 8, 10], 1=>[1, 3, 5, 7, 9]}  


--
Simon Strandgaard