mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update documentation for Array/Hash Argument section of methods.rdoc [Bug #16514] --- doc/syntax/methods.rdoc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
348a909ab9
commit
aa19f11dbd
2 changed files with 14 additions and 3 deletions
|
@ -355,12 +355,23 @@ converted to an Array:
|
|||
|
||||
gather_arguments 1, 2, 3 # prints [1, 2, 3]
|
||||
|
||||
The array argument must be the last positional argument, it must appear before
|
||||
any keyword arguments.
|
||||
The array argument must appear before any keyword arguments.
|
||||
|
||||
It is possible to gather arguments at the beginning or in the middle:
|
||||
|
||||
def gather_arguments(first_arg, *middle_arguments, last_arg)
|
||||
p middle_arguments
|
||||
end
|
||||
|
||||
gather_arguments 1, 2, 3, 4 # prints [2, 3]
|
||||
|
||||
The array argument will capture a Hash as the last entry if a hash was sent by
|
||||
the caller after all positional arguments.
|
||||
|
||||
def gather_arguments(*arguments)
|
||||
p arguments
|
||||
end
|
||||
|
||||
gather_arguments 1, a: 2 # prints [1, {:a=>2}]
|
||||
|
||||
However, this only occurs if the method does not declare any keyword arguments.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.6.7"
|
||||
#define RUBY_RELEASE_DATE "2021-02-28"
|
||||
#define RUBY_PATCHLEVEL 159
|
||||
#define RUBY_PATCHLEVEL 160
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2021
|
||||
#define RUBY_RELEASE_MONTH 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue