[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: An idiomatic way to traverse all pairs in an enumerable?

Trans

12/16/2007 2:21:00 PM



On Dec 15, 6:03 pm, "Shot (Piotr Szotkowski)" <s...@hot.pl> 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.rub.../rdoc/core/classes/Enumerable.ht...

T.

http://facets.rub...