How to check if a value exists in an array in Ruby

You’re looking for include?:

>> ['Cat', 'Dog', 'Bird'].include? 'Dog'
=> true

Leave a Comment