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. -- Steven -- http://mail.python.org/mailman/listinfo/python-list