Created
November 13, 2017 17:32
-
-
Save bhuga/07e40e674518b8e2e4d46f77feb46e9f to your computer and use it in GitHub Desktop.
is this a ruby bug or am i misunderstanding something? fails on 2.4.1p111
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
# without a default for x | |
def foo(x, keyword: :b) | |
puts x | |
puts keyword | |
end | |
foo({x: 1}) | |
#{:x=>1} | |
#b | |
# make x's default an empty hash | |
def foo(x={}, keyword: :b) | |
puts x | |
puts keyword | |
end | |
foo({x: 1}, keyword: :c) | |
# {:x=>1} | |
# c | |
foo({x: 1}) | |
# ArgumentError: unknown keyword: x | |
# Why raise? why assume the has is kwargs after giving x a default of {}? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment