From: Dominic Son Date: 2007-02-09T14:42:09+09:00 Subject: Re: Grouping similar attributes Looks good. that would've been nifty if there was a function to automate this...for now looks like we're rolling our own.. i'll be playing with these suggestions. thanks. SunRaySon wrote: > This can help you too... > > def ethnic_group(e, n) > > if @eg.nil? > @eg = {} > end > > if @eg[e].nil? > @eg[e] = [] > end > > @eg[e] << n > return @eg > end > > @eg = nil > > ethnic_group('asian', 'domnic') > ethnic_group('asian', 'john') > ethnic_group('spanish', 'rich') > > p @eg -- Posted via http://www.ruby-forum.com/.