path: root/doc
diff options
authorJeremy Evans <>2021-11-18 12:44:19 -0800
committerJeremy Evans <>2021-11-18 14:17:57 -0800
commit4adb012926f8bd6011168327d8832cf19976de40 (patch)
tree9457020694002d0a0c07ced988a1d09c79fa74e6 /doc
parentea02b93bb95a42439631606269659dffc1981883 (diff)
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 Co-authored-by: Nobuyoshi Nakada
Notes: Merged:
Diffstat (limited to 'doc')
1 files changed, 8 insertions, 1 deletions
diff --git a/doc/syntax/methods.rdoc b/doc/syntax/methods.rdoc
index e86cc2c00c..2bb350def1 100644
--- a/doc/syntax/methods.rdoc
+++ b/doc/syntax/methods.rdoc
@@ -515,8 +515,15 @@ Most frequently the block argument is used to pass a block to another method:
+You are not required to give a name to the block if you will just be passing
+it to another method:
+ def each_item(&)
+ @items.each(&)
+ end
If you are only going to call the block and will not otherwise manipulate it
-or send it to another method using <code>yield</code> without an explicit
+or send it to another method, using <code>yield</code> without an explicit
block parameter is preferred. This method is equivalent to the first method
in this section: