Skip to content

Instantly share code, notes, and snippets.

/super.rb Secret

Created January 16, 2015 11:48
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 anonymous/f187d8f51ffb0e0261f1 to your computer and use it in GitHub Desktop.
Save anonymous/f187d8f51ffb0e0261f1 to your computer and use it in GitHub Desktop.
a = Class.new do
def foo
yield
end
end
b = Class.new(a) do
def foo
super{
"b"
}
end
end
p b.new.foo{"c"} # => "b"
c = Class.new do
def foo(&block)
block.call
end
end
d = Class.new(c) do
def foo(&block)
block = -> { "b" }
super
end
end
p d.new.foo{"c"} # => "c"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment