Skip to content

Instantly share code, notes, and snippets.

@kamipo
Created February 25, 2021 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamipo/69b895af8d13d2e4445654378e51db70 to your computer and use it in GitHub Desktop.
Save kamipo/69b895af8d13d2e4445654378e51db70 to your computer and use it in GitHub Desktop.
using Module.new {
refine Enumerable do
alias :orig_sum :sum
end
}
module Enumerable
def sum(...)
p method(:orig_sum)
end
end
class A
include Enumerable
end
class B
include Enumerable
def sum(...)
super
end
end
p RUBY_VERSION
A.new.sum
B.new.sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment