Skip to content

Instantly share code, notes, and snippets.

@stephenprater
Created November 9, 2013 06:21
Show Gist options
  • Save stephenprater/7382383 to your computer and use it in GitHub Desktop.
Save stephenprater/7382383 to your computer and use it in GitHub Desktop.
explicitly passed block argument is implicitly passed with super - ?
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