Last active
July 26, 2018 17:48
-
-
Save joallard/4893ed859116f1a81761ffc440db64e9 to your computer and use it in GitHub Desktop.
Does a bare call to super take into account modified arguments? Also see: https://stackoverflow.com/questions/27981314/calling-super-without-arguments
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(**opts) | |
opts.merge(a: true) | |
end | |
end | |
class B < A | |
def foo(**opts) | |
opts[:b] = true | |
super | |
end | |
end | |
class C < A | |
def foo(**opts) | |
opts = {completely: :different} | |
opts[:c] = true | |
super | |
end | |
end | |
puts B.new.foo(original: 1) # {:original=>1, :b=>true, :a=>true} | |
puts C.new.foo(original: 1) # {:completely=>:different, :c=>true, :a=>true} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment