From: Shashank Date Date: 2002-06-09T23:18:19+09:00 Subject: Re: Unflatten Excellent suggestions, Joel, I have added them my perosnal "goodies" library. And you are right, they do address a different but similar problem. I am studying your solution and being a newbie it is taking me a while for it to sink in ;-), but I am getting there. Thanks again. "Joel VanderWerf" wrote in message news:3D013DB0.5811BD55@path.berkeley.edu... > Joel VanderWerf wrote: > > module Enumerable > > def nest(&compare) > .. > > FWIW, I just realized that a grouping can be done very easily using > #nest: > > module Enumerable > def group(&test) > nest { |x| test[x] ? 1 : 0 } > end > end > > p [1, 2, "three", "four", 5, "six"].group { |x| x.is_a? String } > > ==> [1, 2, ["three", "four"], 5, ["six"]] >