Hi --

On Fri, 17 Nov 2006, spooq wrote:

> On 11/17/06, dblack / wobblini.net <dblack / wobblini.net> wrote:
>> Hi --
>> 
>> On Fri, 17 Nov 2006, spooq wrote:
>> 
>> >> I don't think dup'ing plays well with the intent, which is to do a
>> >> kind of pass-through of the object itself.
>> >
>> > The original object -is- getting passed through... the point is to
>> > prevent modification of it. That's what map! and each are for.
>> 
>> I see what you mean.  Well, as per my gsub! example, I think modifying
>> it can be useful :-)
>
> This can be rewritten using existing keywords tho... if you want to
> actually use the original, use each and gsub!, or if you want to use
> the output, then use map and gsub. Doing both at the same time just
> means that your nice single chain of operations will either
>
> a) end up giving you the same end result as your input is now modified
> to be, which you have to admit is not very useful
>
> or
>
> b) somewhere else along the chain you'll stop modifying one, which is
> going to be hideously confusing.
>
> If the original and the output share steps, make that obvious.

I'm afraid I don't follow.  Can you show how you'd write this in the
ways you've described?  Since you can't reliably chain gsub! with
anything else, I'm not sure how it would play out.


David

-- 
                   David A. Black | dblack / rubypal.com
Author of "Ruby for Rails"   [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog)        [2] | Co-director, Ruby Central, Inc.   [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com    | [4] http://www.rubycentral.org