Actions
Feature #14778
closedMake Object#dup accept a block
    Feature #14778:
    Make Object#dup accept a block
  
Status:
Feedback
Assignee:
-
Target version:
-
Description
I'd like to use Object#dup with a block, which is equivalent to dup.tap.
An example for dup.tap is here.
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
Actions