On Thu, Jul 29, 2010 at 12:40 PM, David Masover <ninja / slaphack.com> wrote:

> Do this:
>
> string.tap {|x| x << 'foo'}
>

A nice use of #tap (IMO, and these things are very much a matter of opinion):

  message = String.new.tap { |s|
    s << "..."
    s << "..."
    if some_condition?
      s << "..."
    else
      s << "..."
    end
  end

Gavin