From: dblack@... Date: 2006-11-08T11:27:15+09:00 Subject: Re: can you rubyfy this? On Wed, 8 Nov 2006, David Vallner wrote: > Jeff Pritchard wrote: >> >> Multi-line {} blocks are legal but not the "expected" way. The rest of >> it looks ok to me. >> > > I claim subject to fashion / taste - I can't recall do/end being used > much for blocks at all when I joined the list in the wild, wild days of > 1.8.2 *duck* Arriviste :-) I got curious about this, so here are some very rough-and-ready stats. First, Ruby 1.8.2. $rfiles is all the .rb files in the standard lib. # {|| } blocks $ grep "{ \?|" $rfiles | wc -l 1729 # {|| } blocks on multiple lines $ grep "{ \?|" $rfiles | grep -v "}" | wc -l 724 # do blocks $ grep " do " $rfiles | wc -l 1130 # do blocks on multiple lines $ grep " do " $rfiles | grep -v "end" | wc -l 1093 Here's the same for 1.8.5: Braces: 1121 Braces on multiple lines: 379 do/end: 1275 do/end on multiple lines: 1237 Summary: Block use in general is down. Or my grepping is even cruder than it looks :-) do/end has gained some popularity, relative to all blocks (53% of all blocks vs. 39%). do/end is, and was, more common for multi-line blocks. David -- David A. Black | dblack@wobblini.net 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