3
How do I check if a certain value is contained in a Ruby array? For example, I want to know if 'A' is present in the vector ['A','B','C'].
3
How do I check if a certain value is contained in a Ruby array? For example, I want to know if 'A' is present in the vector ['A','B','C'].
2
Use the method include?.
a = [ "a", "b", "c" ]
a.include?("b") #=> true
a.include?("z") #=> false
Browser other questions tagged array ruby
You are not signed in. Login or sign up in order to post.