From: "David A. Black" Date: 2005-05-13T00:57:42+09:00 Subject: Re: {} vs begin/end [was Re: object loops and what they return] Hi -- On Fri, 13 May 2005, Jim Weirich wrote: > > David A. Black said: >> I know, it's not 100% reliable... but it suggests that, at least >> roughly, 3% of 'do' blocks end on the same line, while 62% of {} >> blocks end on the same line. So this "odd" behavior is actually >> pretty canonical :-) > > Hmmm ... More statistics, same code base, same disclaimers. > > dev05$ find . -name '*.rb' | xargs egrep '(each|loop) *do' | wc -l > 1112 > dev05$ find . -name '*.rb' | xargs egrep '(each|loop) *{' | wc -l > 878 > dev05$ find . -name '*.rb' | xargs egrep > '(collect|map|find|find_all|select|((inject|grep) *\(.*\))) *do' | wc -l > 68 > dev05$ find . -name '*.rb' | xargs egrep > '(collect|map|find|find_all|select|((inject|grep) *\(.*\))) *{' | wc -l > 657 > > So, nearly 55% of methods that ignore the return value of the block use > do/end. > > Over 90% of the methods that use the block's value use {}. > > So you can use either style and claim to be main-stream. It looks like you can only claim to be mainstream if you use *both* styles :-) Or am I reasoning wrongly? David -- David A. Black dblack@wobblini.net