Created
November 9, 2013 06:21
-
-
Save stephenprater/7382383 to your computer and use it in GitHub Desktop.
explicitly passed block argument is implicitly passed with super - ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
def foo(a = 'foo', &b) | |
puts a | |
yield if block_given? | |
end | |
end | |
class B < A | |
def foo(a, &b) | |
puts a | |
yield if block_given? | |
super() | |
end | |
end | |
B.new.foo(1) { puts "boo" } | |
#=> | |
# 1 | |
# boo | |
# foo | |
# boo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment