Issue #14778 has been reported by hkdnet (Ko Sato).

----------------------------------------
Feature #14778: Make Object#dup accept a block
https://bugs.ruby-lang.org/issues/14778

* Author: hkdnet (Ko Sato)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I'd like to use `Object#dup` with a block, which is equivalent to `dup.tap`.

An example for `dup.tap` is here.

```ruby
require 'uri'

module MyUri
  class << self
    def foo_uri
      base_uri.dup.tap { |e| e.path = '/foo' }
    end

    private

    def base_uri
      @base_uri ||= URI.parse('http://example.com')
    end
  end
end
```

With this patch, we can write `base_uri.dup { |e| e.path = '/foo' }` and it's simpler.

---Files--------------------------------
dup_with_block.diff (296 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>