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?
(I assume I could finally grasp the whole block-passing side of Ruby
and write my own Enumerable#each_mix, but maybe there’s something there
already. Note: Enumerable#each_pair doesn’t cut it, as it’s just for
neighbouring element pairs, while I need something for all possible
pairs.)
Thanks in advance for any help with the above!
– Shot