Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: some inappropriate behaviors in keyword arguments #497

Open
hachi8833 opened this issue Oct 31, 2017 · 0 comments
Open

Bug: some inappropriate behaviors in keyword arguments #497

hachi8833 opened this issue Oct 31, 2017 · 0 comments
Labels
Milestone

Comments

@hachi8833
Copy link
Member

They are edge cases when keyword args are not provided.

1:

def foo(a: 1)
  puts a
end

foo
#=> 1   # ok

foo a: 99
#=> 99  # ok

foo 99
#=> 1   # wrong: should be ArgumentError

2:

def foo(a, b:)
  puts a
  puts b
end

# ok
foo "bar", b: "baz"
#=> bar
#=> baz

# wrong
foo b: "baz"
#=> baz    # wrong: should also be ArgumentError, and unassigned variable 'a' should not be 'baz'
#=> baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants