Vote count:
0
I have this array :
>> arr = [["a",1,"b"],["a",2,"b"],["b",3,"d"],["t",6,"a"]]
I want to check if ["a",1] exists inside the arr
while ignoring the 3rd value of the arr
items.
Is there a better way then first removing the 3rd value from each item in arr
:
>> new_arr = [["a",1],["a",2],["b",3],["t",6]]
and then doing
>> new_arr.include? ["a",1]
true
Something like:
arr.include? ["a",1,/*/] #the 3rd value can be anything
Thanks.
asked 44 secs ago
Check if partial value is inside array
Aucun commentaire:
Enregistrer un commentaire