Array inclusion checking with Ruby -


i need check if array

a1 = [x, y]  

is presented in array of arrays like

a2 = [ [a, b], [c,d], [e, f] ] 

with ruby 1.9. example, if x == c , y == d function must true. i'v tried

a2.includes? a1 , a1 in a2 both doesent work.

see used includes?, should include?.

a2 = [ [:a, :b], [:c,:d], [:e,:f] ] a1 = [:a,:b]  p a2.include? a1 #=>true 

or below:

a2 = [ [:a, :b], [:c,:d], [:e,:f] ] a1 = [:a,:b]  p a2.one? { |i| == a1} #=>true 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -