I'm somehow surprised about this long discussion, based on my short question, 
but now I have a question regarding "tap".

David A. Black schrieb:
 >> On Nov 16, 2007 3:19 PM, David A. Black <dblack / rubypal.com> wrote:
 >> str.downcase.split...
 > I'm assuming we're talking about a case where someone wants (for
 > whatever reason) str itself to be permanently downcased.

I must admit that this example may be misleading. The basis is that I don't want 
to use "str.downcase.split", because the copy build by "downcase" is only needed 
once. Otherwise "str.downcase!.split" can't be used, because "downcase!" returns 
"nil" if nothing was changed. "str.tap(&:downcase!).split" does the job, so from 
my viewpoint everything is solved.

Now I started to look a little bit deeper to "tap".

irb(main):001:0> "abc".tap{|s|s+"def"}
=> "abc"

This does exactly what expected, but here...

irb(main):002:0> "abc".tap{|s|break s+"def"}
=> "abcdef"

...I was surprized. I know, that this is what "break" usually does, but somehow 
I expected a different behaviour, that can be expressed by the combination 
(example only!!!!!)...

irb(main):003:0> def _____;end
=> nil
irb(main):004:0> "abc".tap{|s|_____{break s+"def"}}
=> "abc"

...where I expected that tap puts this hidden "shelter block" around the code of 
the "tap" block.

Isn't it the intention for "tap" to hinder the code of the block to return a 
different object that self?

Wolfgang NĂ¡dasi-Donner