How to check if a certain value is contained in an array in Ruby? For example, I want to know if 'A'
is present in the ['A','B','C']
vector.
How to check if a certain value is contained in an array in Ruby? For example, I want to know if 'A'
is present in the ['A','B','C']
vector.
Use the include?
method.
a = [ "a", "b", "c" ]
a.include?("b") #=> true
a.include?("z") #=> false