I need to patch a class, but want the patch be local to some module(s). In Ruby I would do:
module ArrayExtension
refine Array do
def ===(other)
self.include?(other)
end
end
end
module Foo
using ArrayExtension
def self.foo
case 2
when [1,2] then puts "bingo!"
end
end
end
Foo.foo # => bingo!
puts [1,2] === 2 # => false
Is there something similar in Crystal?
So to redefine
===
you just define it again.