Came across a need for this in a somewhat silly golfing exercise, but
I was wondering if there was any real use for it, and if it had a name
in some language somewhere. It essentially lets a block of code be
inserted into a method chain (a la Object#tap) but returns the return
value of the block rather than the passed in argument.

for example (using "apply" for want of a better name)

array.inject({}).map {|h, e| h[e] = f(e); h}

would become

array.map {|e| e, f(e)}.flatten.apply {|x| Hash[*x]}

martin