Граф коммитов

43 Коммитов

Автор SHA1 Сообщение Дата
Jeremy Evans f53dfab95c Add support for anonymous rest and keyword rest argument forwarding
This allows for the following syntax:

```ruby
def foo(*)
  bar(*)
end
def baz(**)
  quux(**)
end
```

This is a natural addition after the introduction of anonymous
block forwarding.  Anonymous rest and keyword rest arguments were
already supported in method parameters, this just allows them to
be used as arguments to other methods.  The same advantages of
anonymous block forwarding apply to rest and keyword rest argument
forwarding.

This has some minor changes to #parameters output.  Now, instead
of `[:rest], [:keyrest]`, you get `[:rest, :*], [:keyrest, :**]`.
These were already used for `...` forwarding, so I think it makes
it more consistent to include them in other cases.  If we want to
use `[:rest], [:keyrest]` in both cases, that is also possible.

I don't think the previous behavior of `[:rest], [:keyrest]` in
the non-... case and `[:rest, :*], [:keyrest, :**]` in the ...
case makes sense, but if we did want that behavior, we'll have to
make more substantial changes, such as using a different ID in the
... forwarding case.

Implements [Feature #18351]
2021-12-30 14:37:42 -08:00
Jeremy Evans 4adb012926 Anonymous block forwarding allows a method to forward a passed
block to another method without having to provide a name for the
block parameter.

Implements [Feature #11256]

Co-authored-by: Yusuke Endoh mame@ruby-lang.org
Co-authored-by: Nobuyoshi Nakada nobu@ruby-lang.org
2021-11-18 14:17:57 -08:00
Jeremy Evans ee1725cecb Update keyword argument description in method syntax guide
Remove discussion of Ruby 2.7 specific handling of keyword
argument separation.  Add a small example of keyword to
positional hash conversion for methods not accepting
keyword arguments.
2021-05-11 15:45:52 -07:00
wonda-tea-coffee fc84e6679d [Doc] Fix a typo s/invokations/invocations/ 2021-04-25 19:45:01 +12:00
Marcus Stollsteimer 3fc53de5c9 methods.rdoc: Improve method definition documentation
* typos, grammar, formatting
* use `concrete_method` again in `regular_method` example,
  to better distinguish from `forwarding_method` example
* clarify that leading arguments before `...` require Ruby 3.0
2020-12-26 10:40:52 +01:00
Marcus Stollsteimer ce65a7687f methods.rdoc: Clarify "currently" means "in 2.7" here 2020-12-26 10:40:47 +01:00
zverok 255ee4de8c Update method definition documentation
* Add endless methods
* Add argument forwarding ...
2020-12-25 22:10:09 +09:00
Nobuyoshi Nakada aaf0474e76
Adjusted the heading level of "Block Arguments" [ci skip] 2020-12-25 22:09:22 +09:00
Adam Isom 09271acdaf Update documentation for Array/Hash Argument section of methods.rdoc 2020-01-17 19:50:39 +09:00
Marcus Stollsteimer 66e518f7b3 [DOC] Fix typo 2019-12-24 13:01:24 +01:00
Jeremy Evans c7715a4936 Add documentation regarding keyword argument separation [ci skip] 2019-10-03 14:13:27 -07:00
Jeremy Evans 12e27a411c Minor updates to methods and calling_methods documentation [ci skip] 2019-10-03 14:13:27 -07:00
Jeremy Evans c945d115a5 Document use of ensure and else at method level [ci skip] 2019-07-19 11:39:05 -07:00
Jeremy Evans ceeb1535dd Remove section on performance advantage of not using a block parameter [ci skip]
Improvements in Ruby 2.5 and 2.6 make this section no longer
accurate.
2019-07-19 11:38:49 -07:00
Jeremy Evans 7e2677675d Remove mention of Proc.new with implicit block [ci skip]
This support is now deprecated and will be removed in Ruby 3.
2019-07-19 11:38:49 -07:00
Jeremy Evans bf2f84b2ff Document evaluation order of arguments [ci skip]
Fixes [Misc #8905]
2019-07-19 11:38:49 -07:00
Jeremy Evans 71d21f3c75 Document required keyword argument syntax [ci skip]
Fixes [Bug #8952]
2019-07-19 11:38:42 -07:00
rhe 171f968d22 doc/syntax/methods.rdoc: fix a misleading example
As a bonus, wrap a long line added by r60295.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 04:19:03 +00:00
svn cd381d8acc * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:19:46 +00:00
hsbt 86f1d9b705 Clarify return value for assignment methods.
https://github.com/ruby/ruby/pull/1682

  Patch by @sos4nt [fix GH-1682]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:19:45 +00:00
stomar 46eed7b80b methods.rdoc: small improvements
* doc/syntax/methods.rdoc: [DOC] small improvements: fix some typos,
  grammar, punctuation, consistently use capitalized "Ruby".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-29 19:12:01 +00:00
nobu d70a84d5d4 methods.rdoc: closing tag
* doc/syntax/methods.rdoc (Method Names): add proper closing tag.
  [Fix GH-1356]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-21 02:07:31 +00:00
hsbt 4f94cb43fc * doc/syntax/*.rdoc: separated modifier at sentence.
[ci skip][fix GH-1121] Patch by @clandry94

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-18 03:39:49 +00:00
hsbt d9a2b3480e * doc/contributors.rdoc: fix a typo. Patch by @davydovanton
[fix GH-872][ci skip]
* doc/syntax/methods.rdoc: ditto.
* ext/digest/sha2/sha2.c: ditto.
* ext/socket/ipsocket.c: ditto.
* ext/tk/*: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-15 01:37:47 +00:00
hsbt c5e9d76221 * doc/syntax/methods.rdoc: add some missing spaces and
fix a grammatical error in method docs.
  [fix GH-843][ci skip] Patch by @nikolas

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-04 01:15:43 +00:00
nobu 1a65cef0f0 doc: remove trailing spaces
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-23 00:13:32 +00:00
zzak f13f9f6946 * doc/syntax/methods.rdoc: [DOC] [] and []= methods by @process
[Fixes GH-662] https://github.com/ruby/ruby/pull/662


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-22 10:50:52 +00:00
zzak 31fa4d8899 * doc/syntax/methods.rdoc: [DOC] Fix example for block arguments [ci skip]
By @idupree [Fixes GH-554] https://github.com/ruby/ruby/pull/554


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-06 06:08:40 +00:00
zzak 573762a7b7 * doc/syntax/methods.rdoc: [DOC] Added example for underscore
conventions in method names. Also added doc to clarify encoding
  character set support for Ruby programs and elaborated on defining
  predicate and bang methods. Based on a patch by @gaurish
  [Fixes GH-477] https://github.com/ruby/ruby/pull/477


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-22 20:13:09 +00:00
drbrain 6ff1653cf6 * doc/syntax/assignment.rdoc: Improved links
* doc/syntax/methods.rdoc:  ditto.

	* doc/syntax.rdoc:  Added link to assignment document


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-19 00:16:08 +00:00
drbrain 1d5a5c235f * doc/syntax/methods.rdoc: Added Array Decomposition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-18 05:15:44 +00:00
drbrain 4cf9fa309d * doc/syntax/calling_methods.rdoc: Link to defining methods.
* doc/syntax/methods.rdoc:  Link to calling methods, fixed typo.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-15 18:29:05 +00:00
drbrain 8113321482 * doc/syntax/methods.rdoc: Fixed link
* doc/syntax/modules_and_classes.rdoc:  Fixed link
* doc/syntax.rdoc:  Updated with links to the recently added pages


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-15 18:15:12 +00:00
drbrain 68b072bfba * doc/syntax/methods.rdoc (Method Names): Added method names including
operator methods.
* doc/syntax/methods.rdoc (Return Values):  Added note that assignment
  methods ignore return values.
* doc/syntax/precedence.rdoc:  Added document describing precedence.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-15 04:33:28 +00:00
drbrain 108f3acbe4 * doc/syntax/methods.rdoc (Block Argument): Added section on block
argument.  Thanks to Andy Lindeman.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-15 02:49:54 +00:00
drbrain eeee190882 * doc/syntax/methods.rdoc (Array/Hash Argument): Moved above Keyword
Arguments
* doc/syntax/methods.rdoc (Keyword Arguments):  Described ** for
  gathering arbitrary keyword arguments.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-15 00:11:46 +00:00
drbrain a13aee62d2 * doc/syntax/modules_and_classes.rdoc: Added documentation of syntax
for Modules and Classes.
* doc/syntax/methods.rdoc:  Moved some text to the Modules and
  Classes syntax document.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-05 01:23:49 +00:00
drbrain 1da85070b0 * doc/syntax/methods.rdoc: Added return values and scope sections,
slightly modified from the original patch.  Fixes #227 from github by
  Dave Brown.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-04 23:39:48 +00:00
marcandre 542a12d673 * doc/syntax/methods.rdoc: rdoc fix, patch by Dave Brown
[github:222]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-19 09:05:44 +00:00
drbrain d8cda04488 * doc/syntax/methods.rdoc: Fixed typo. Thanks to Josh Susser.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-19 07:19:59 +00:00
drbrain 2c0d2db5cb * doc/syntax/methods.rdoc: Add () around keyword arguments example for
consistency.  Thanks to Josh Susser.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-19 06:24:02 +00:00
drbrain 73b244d0de * doc/syntax/methods.rdoc: Added a description of singleton methods.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-17 03:05:45 +00:00
drbrain 29fd593475 * doc/syntax.rdoc: Added syntax guide table of contents
* doc/syntax/exceptions.rdoc:  Syntax guide for exceptions
* doc/syntax/literals.rdoc:  Syntax guide for literals
* doc/syntax/methods.rdoc:  Syntax guide for methods


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-17 02:26:15 +00:00