From: James Edward Gray II Date: 2005-06-13T22:09:45+09:00 Subject: Re: finding Hash subsets based on key value On Jun 13, 2005, at 3:55 AM, Robert Klemme wrote: > Martin DeMello wrote: > >> Robert Klemme wrote: >> >>> >>> IMHO we should have a general partitioning method (probably in >>> Enumerable) that does partitioning into several buckets and not just >>> two. Something like this maybe: >>> >>> module Enumerable >>> def general_partition >>> >> >> I like it, but not the name. partition_by, perhaps. >> > > Yes, this is *much* better! The Set class has this feature and I even like the name: irb(main):001:0> require "set" => true irb(main):002:0> langs = Set.new([:perl, :python, :ruby]) => # irb(main):003:0> langs.classify { |m| m.to_s[0, 1] } => {"p"=>#, "r"=>#} James Edward Gray II