module Enumerable
def sole
Set.new.sole # => Enumerable::SoleItemExpectedError: no item found
["x"].sole # => "x"
than one item, raises +Enumerable::SoleItemExpectedError+.
Returns the sole item in the enumerable. If there are no items, or more
def sole case count when 1 then return first # rubocop:disable Style/RedundantReturn when 0 then raise ActiveSupport::EnumerableCoreExt::SoleItemExpectedError, "no item found" when 2.. then raise ActiveSupport::EnumerableCoreExt::SoleItemExpectedError, "multiple items found" end end