On Feb 19, 9:30 am, Steven D'Aprano <st...@remove-this- cybersource.com.au> wrote: > On Fri, 19 Feb 2010 08:32:53 -0800, Steve Howell wrote: > > The extra expressiveness of Ruby comes from the fact that you can add > > statements within the block, which I find useful sometimes just for > > debugging purposes: > > > debug = true > > data = strange_dataset_from_third_party_code() > > data.each { |arg| > > if debug and arg > 10000 > > puts arg > > end > > # square the values > > arg * arg > > } > > How is that different from this? > > debug = true > data = strange_dataset_from_third_party_code() > for i, arg in enumerate(data): > if debug and arg > 10000 > print arg > # square the values > data[i] = arg * arg > > I don't see the extra expressiveness. What I see is that the Ruby snippet > takes more lines (even excluding the final brace), and makes things > implicit which in my opinion should be explicit. But since I'm no Ruby > expert, perhaps I'm misreading it. >
You are reading the example out of context. Can you re-read the part you snipped? The small piece of code can obviously be written imperatively, but the point of the example was not to print a bunch of squares. -- http://mail.python.org/mailman/listinfo/python-list