From: furtive.clown@... Date: 2007-11-13T06:25:16+09:00 Subject: Re: alias_method :tap, :affect On Nov 12, 3:55 pm, James Edward Gray II wrote: > On Nov 12, 2007, at 2:40 PM, furtive.cl...@gmail.com wrote: > > I guess I want to see some more examples, because I'm seriously > doubting the usefulness. The example you showed so far was using it > to create this: > > platform_audio_files = audio_stems.map { |f| > f + "." + audio_ext[platform] > }.as { |t| > t + audio_basenames > }.map { |f| > File.join(audio_dir, f) > } > > instead of: > > platform_audio_files = (audio_stems.map { |f| > f + "." + audio_ext[platform] > } + audio_basenames).map { |f| > File.join(audio_dir, f) > } > > I don't really understand what the problem is with the second version > that's shorter and easier for me to understand. If it's the need to > introduce some parentheses into the call chain, we can fix that: > > platform_audio_files = audio_stems.map { |f| > f + "." + audio_ext[platform] > }.concat(audio_basenames).map { |f| > File.join(audio_dir, f) > } > > So yes, please send more examples as I remain unconvinced. It was only a coincidence that you found an Array method which corresponded to the operation in the block, namely Array#concat. Your example breaks down once the operation is nontrivial --- something more complex than '+'. We can also introduce temporaries inside the block without causing distraction in the outer scope. The purpose of the block chain is to produce a value for platform_audio_files; a flood temporary variables on the same scope obscures this purpose.