Actually, how about giving the proc a copy of the object, rather than
the real deal?

class Object
  def tap
    yield self.dup
    self
  end
end

On 11/17/06, spooq <spoooq / gmail.com> wrote:
> I definitely think of it as tapping a phone line.
>
> a.map.map.map.map
>
> eavesdrop = Proc.new { |secret| puts secret }
>
> a.map.map.tap(&eavesdrop) .map.map
>
> It lets me get into the line and hear what's going on without changing
> any existing behaviour. Using a proc that modifies secret is not a
> good idea, just keep it for things with other types of side-effects.
> There's no way to mark the object read-only for the purposes of the
> passed-in proc, is there?
>
> I haven't seen anything to change my mind about the other use. It just
> seems pointless.
>