From: Trans Date: 2007-12-16T23:21:26+09:00 Subject: Re: An idiomatic way to traverse all pairs in an enumerable? On Dec 15, 6:03 pm, "Shot (Piotr Szotkowski)" wrote: > I seem to end up doing the following quite a lot: > > enum.each do |a| > enum.each do |b| > next if a >= b > # do_something with a and b > end > end > > In general, I'm looking for an idiomatic way of traversing each > possible pair of a given enum's contents (once). Is there a more > compact construct? Facets exits for you. http://facets.rubyforge.org/rdoc/core/classes/Enumerable.html#M000450 T. http://facets.rubyforge.org