Question:
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 vector ['A','B','C']
.
Answer:
Use the include?
method include?
.
a = [ "a", "b", "c" ]
a.include?("b") #=> true
a.include?("z") #=> false