From: Robert Klemme Date: 2013-02-15T02:04:23+09:00 Subject: Re: Best DRY way to write bang versions of methods? On Thu, Feb 14, 2013 at 1:43 PM, Edoardo Rossi wrote: > IMHO sometimes this is useful: > > def foo(something) > dup.foo!(something) > end > > def foo!(something) > # do the work... > end There is one gotcha in this code: foo! will often return nil if nothing is changed. A better approach is def foo(something) dup.tap {|copy| copy.foo!(something)} end Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/