Feature #15419
Updated by shuber (Sean Huber) almost 6 years ago
Tapping methods without any arguments already has nice shorthand via `Symbol#to_proc`:
```ruby
object.tap { |o| o.example }
# vs
object.tap(&:example)
```
Unfortunately once other arguments are involved we have to switch back to the longer form:
```ruby
array.merge(other).tap { |a| a.delete(object) }
```
[This patch introduces](https://github.com/ruby/ruby/pull/2050) a convenient and familiar shorthand for these cases which behaves similar to `Kernel#send`:
```ruby
array.merge(other).tap(:delete, object)
```
Calling tap without any arguments or block still raises `LocalJumpError`:
```ruby
3.tap #=> LocalJumpError: no block given
```
This also makes the existing shorthand even shorter:
```ruby
object.tap { |o| o.example }
# vs
object.tap(&:example)
# vs
object.tap(:example)
```
---
**Pull request**: https://github.com/ruby/ruby/pull/2050