Let's say I have an @array = [1 ,2 ,3]
I want to create three blocks of each number of the array with the rest like this :
@array.each do |first|
(@array - [first]).each do |second|
(@array - [first] - [second]) do |third|
#do something
So each block iterates through the entire array except the element that's being used by the preceding block. But this is kind of smelly and repetitive, because for each block I need to delete the preceding elements , what is the best way to refactor these blocks?
Thanks