summaryrefslogtreecommitdiff
path: root/doc/syntax/methods.rdoc
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-07-19 09:58:20 -0700
committerJeremy Evans <code@jeremyevans.net>2019-07-19 11:38:42 -0700
commit71d21f3c750f41ab44e618162515bd9e4a9f289e (patch)
treecce330726414917b9108cee4e2af761817e69ffb /doc/syntax/methods.rdoc
parent57b7bfad9e6421fb8387698908e06dcf363df213 (diff)
Document required keyword argument syntax [ci skip]
Fixes [Bug #8952]
Diffstat (limited to 'doc/syntax/methods.rdoc')
-rw-r--r--doc/syntax/methods.rdoc11
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.