views:

72

answers:

3

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

+2  A: 

you can use:

array.index('two')

will return index of object if present else will return nil.

Ankit
+10  A: 

array.include?('two') returns true or false

zetetic
+2  A: 

http://ruby-doc.org/core/classes/Array.html#M002203

array.include?('two')
Amadan