From: "Matthias Wächter" Date: 2007-09-04T23:15:58+09:00 Subject: Re: with On 04.09.2007 15:28, Paul Brannan wrote: > On Tue, Sep 04, 2007 at 06:50:43AM +0900, Matthias W?chter wrote: >> Ruby tries to avoid local variables wherever it can by chaining >> iterators together like in file-open-each-line-gsub. I tried to allow >> a block to be used for non-enumerable types as well. > > Ruby doesn't try to avoid local variables; this is something you have > done. IMO it's not a good idea. If there's a bug anywhere in your > chain and one of the methods you call returns the wrong type (nil, for > example), then debugging becomes more difficult. Flow is generally from top to bottom (in a file) and from left to right in a line. If there were not function calling and assignment which work some kind of upstream, i.e. right to left. .with introduces downstream function calling without the need for rewriting code _around_ the whole statement and introducing more variables. It even helps debugging. If I am not sure about a value I can simply add ".with {|x| puts "Debugging the expression: #{x}"}" within an expression. Certainly, I might have to add a paren around the expression for ordering stuff correctly, but I don't have to split things apart. FWIW, I have not touched the field of debugging with Ruby yet, so allow me a second opinion on this later :) - Matthias