Anyone who can help me make this work?
array.each_with_index do |buffer,index|
if array[index][8] == array[1..7][8]
puts "match found"
end
end
I want to compare if there is any doublets, but how do i define the search range to be my array index value from 1 to 7 except the index?
just to make it clear i want to compare array[1][8],[2][8],[3][8] and so on except [index][8]
Thanks 4 ur help…
You could use
group_byto create groups of any doublets:This’ll give you a hash of
{"group key" => ["group", "members"]}.To get a list of all doublets, just select the groups that have more than one member:
Furthermore, to eliminate any doublets from the list:
This will return a new array with any doublets eliminated, so that only the first item in any given doublet is returned.