“Useless Ruby sugar”: Argument forwarding

This blog post is part of a series discussing controversial syntax elements introduced in recent Ruby versions. In this particular post, the author focuses on a set of shortcuts for argument forwarding, which haven’t received much pushback from the community. The syntax allows developers to pass all positional, named, and block arguments to another method using the “…” symbol. Ruby 3.1 introduced the ability to forward anonymous block arguments separately, while Ruby 3.2 added support for forwarding positional and named arguments separately. The author highlights that these shortcuts improve code performance by eliminating the need for unnecessary object allocations. The syntax changes were quickly accepted due to their simplicity and practicality. Additionally, the author mentions that the shortcuts can be used in various scenarios, not just for method delegation. However, there are some quirks and limitations, such as the need for parentheses in certain cases and the lack of support for anonymous forwarding in blocks and procs. Overall, the author emphasizes the benefits of these syntax changes in terms of code clarity and expressiveness.

https://zverok.space/blog/2023-11-24-syntax-sugar4-argument-forwarding.html

To top