Your result is confusing me:

{{‘x’=>1,‘w’=>1}=>[0,3],{‘x’=>3,‘w’=>3}=>[2],{‘x’=>5,‘w’=>4}=>[4],{‘x’=>6,

‘w’=>5}=>[5]}.

Not really sure what you’re trying to accomplish, if you want to

determine the indices at which two arrays contain identical values,

you could try:

def comp arr1, arr2

res=[]

arr1.each_with_index {|val, i|

res.push val==arr2[i]

}

end

comp [1,1,3,1,5,6], [1,2,3,1,4,5] # -> [true, false, true, true, false,

false]

if you’d like to determine which values occur in both arrays, try the

intersection operator `&`

:

[1,1,3,1,5,6] & [1,2,3,1,4,5] # -> [1, 3, 5]

-tim