Does Ruby make a string equal to one of the strings in an array of strings?

Is there an easy way to sort a call with something similar to a database In query?

Does "mystring" exist in ["string1", "mystring", "string2"] => will return true

Does "mystring" exist in ["string1", "string2", "string3"] => returns false

+6
source share
1 answer
["string1","mystring","string2"].include? "mystring" 

See: Enumerable # include?

+8
source

Source: https://habr.com/ru/post/913860/


All Articles