diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-07-19 09:58:20 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-07-19 11:38:42 -0700 |
commit | 71d21f3c750f41ab44e618162515bd9e4a9f289e (patch) | |
tree | cce330726414917b9108cee4e2af761817e69ffb /doc | |
parent | 57b7bfad9e6421fb8387698908e06dcf363df213 (diff) | |
download | ruby-71d21f3c750f41ab44e618162515bd9e4a9f289e.tar.gz |
Document required keyword argument syntax [ci skip]
Fixes [Bug #8952]
Diffstat (limited to 'doc')
-rw-r--r-- | doc/syntax/methods.rdoc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/syntax/methods.rdoc b/doc/syntax/methods.rdoc index a47c1a3cbf..564159ac01 100644 --- a/doc/syntax/methods.rdoc +++ b/doc/syntax/methods.rdoc @@ -398,6 +398,17 @@ When calling a method with keyword arguments the arguments may appear in any order. If an unknown keyword argument is sent by the caller an ArgumentError is raised. +To require a specific keyword argument, do not include a default value +for the keyword argument: + + def add_values(first:, second:) + first + second + end + add_values + # ArgumentError (missing keywords: first, second) + add_values(first: 1, second: 2) + # => 3 + When mixing keyword arguments and positional arguments, all positional arguments must appear before any keyword arguments. |