Possible Duplicate:
how to check if my array includes an object - rails
I have array
array['one', 'two', 'three']
How i find that 'two' element present in array.
Is any method in ruby which can find this?
Thanks
Possible Duplicate:
how to check if my array includes an object - rails
I have array
array['one', 'two', 'three']
How i find that 'two' element present in array.
Is any method in ruby which can find this?
Thanks
you can use:
array.index('two')
will return index of object if present else will return nil.
http://ruby-doc.org/core/classes/Array.html#M002203
array.include?('two')