# frozen_string_literal: true require 'forwardable' require 'set' module FindBangExtension class NotFoundError < StandardError end end Array.class_eval do unless method_defined?(:find!) # :nodoc: def find!(&block) x = find(&block) raise(FindBangExtension::NotFoundError, 'Not found') if x.nil? x end end end Set.class_eval do unless method_defined?(:find!) extend Forwardable def_delegators :to_a, :find! end end