(ruby 1.86)
I have an array made up of arrays like:
>> myArray
=> [["apple", 1], ["bananna", 2], ["peach", 3], ["orange", 4]]
I know I can use the detect method to find the first instance of 'orange' in index[0] of the sub-arrays in MyArray:
myTest = (myArray.detect { |i| i[0] == 'orange' } || []).first
=> orange
If it's possible, how can I have the detect method return the value of the sup-array index position 1. Like, i[0] is being returned, but when i[0] == 'orange' I need i[1] returned.
I need to search for 'orange' and have the return value be 2.
Thank You!