path: root/doc/syntax/calling_methods.rdoc
diff options
authorVictor Shepelev <>2021-12-19 18:09:52 +0200
committerGitHub <>2021-12-20 01:09:52 +0900
commita0f10a973fb94a0ee73da7cab792128cdf601783 (patch)
treee025219312d597d04d0670951c13a867f2f98721 /doc/syntax/calling_methods.rdoc
parent1dd10e189274546689c0b59f6a76849b2808f255 (diff)
[DOC] Add documentation for hash value omission syntax
Notes: Merged: Merged-By: nobu <>
Diffstat (limited to 'doc/syntax/calling_methods.rdoc')
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/syntax/calling_methods.rdoc b/doc/syntax/calling_methods.rdoc
index fc806d5c31..da061dbfdb 100644
--- a/doc/syntax/calling_methods.rdoc
+++ b/doc/syntax/calling_methods.rdoc
@@ -210,6 +210,24 @@ definition. If a keyword argument is given that the method did not list,
and the method definition does not accept arbitrary keyword arguments, an
ArgumentError will be raised.
+Keyword argument value can be omitted, meaning the value will be be fetched
+from the context by the name of the key
+ keyword1 = 'some value'
+ my_method(positional1, keyword1:)
+ # the same as
+ my_method(positional1, keyword1: keyword1)
+Be aware that when method parenthesis are omitted, too, the parsing order might
+be unexpected:
+ my_method positional1, keyword1:
+ some_other_expression
+ # actually parsed as
+ my_method(positional1, keyword1: some_other_expression)
=== Block Argument
The block argument sends a closure from the calling scope to the method.