From: Jim Weirich Date: 2005-05-13T00:24:54+09:00 Subject: Re: {} vs begin/end [was Re: object loops and what they return] 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. -- -- Jim Weirich jim@weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)