I have a rubocop problem while doing my own ruby enumerables. I used a ===
and rubocop is asking me to change it. But every time I try to put something different my method stops working as desired.
module Enumerable
def my_all?(arg = nil)
return true if !block_given? && include?(nil) == false && include?(false) == false && arg.nil?
return false unless block_given? || arg.nil? == false || empty?
if block_given?
my_each do |x|
return false unless yield(x)
end
elsif arg.class == Regexp
my_each do |x|
return false unless x.match(arg)
end
elsif arg.class == Numeric
my_each do |x|
return false unless x.is_a? arg
end
else
my_each do |x|
return false unless arg === x
end
end
true
end
end
That last ===
is offering resistance to be changed. Thanks to the ones that are able to understand this and help!