Created
June 19, 2017 19:48
-
-
Save etscrivner/6bed7d44852746d7d851d1a6ea86a252 to your computer and use it in GitHub Desktop.
Ruby propagates arguments up to super method calls for you
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 Parent | |
def try_me(confirmed_only: true) | |
confirmed_only | |
end | |
end | |
class Child < Parent | |
def try_me(confirmed_only: true) | |
# Ruby will proxy the value of `confirmed_only` up to the super method invocation for you. | |
super | |
end | |
end | |
# Result: `false` | |
puts Child.new.try_me(confirmed_only: false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment