# Ruby
['Cat', 'Dog', 'Bird'].include? 'Dog'
# => true
# Rails ActiveSupport
'Unicorn'.in?(['Cat', 'Dog', 'Bird'])
# => false
# Via case statement
element = 3
array = [1, 2, 3, 4, 5]
case element
when *array
puts 'found in array'
else
puts 'not found in array'
end
You can just use a set difference (aka minus) to see if one array includes all elements of another
not_included = [1,2,3] - (1..9).to_a
not_included # => []
not_included = [1,2,3,'A'] - (1..9).to_a
not_included # => ["A"]