I am trying to populate an array with an intersection of an array and hash based on hash values:
array2 = ["hi","world","One"]
Vals = {:one => "One", :two => "Two"}
array2 = VALS.values & array2
print array2
Works fine for intersection of hash values and array2[ i ], but if I want to instead populate with array2[ i+1 ] element from array2, I am lost.
Also tried:
array2.select { |i| VALS.has_value? i ? array2[i+1] : nil }
But no luck.
Any ideas?