# frozen_string_literal: true class Array # @param threshold [Integer] default 1 # @return [*] first items that appears more than `threshold` times def first_dupe(threshold = 1) find { |item| count(item) > threshold } end end