Convert array to a set: it removes duplicate elements for you
require 'set' survey_results = [1, 2, 7, 1, 1, 5, 2, 5, 1] p distinct_answers = survey_results.to_set # => #<Set: {5, 1, 7, 2}>