From: Chad Perrin Date: 2007-06-13T07:03:02+09:00 Subject: Re: a matter of style On Wed, Jun 13, 2007 at 06:51:54AM +0900, James Edward Gray II wrote: > On Jun 12, 2007, at 4:47 PM, Chad Perrin wrote: > > >On Tue, Jun 12, 2007 at 07:59:10PM +0900, dblack@wobblini.net wrote: > >>On Tue, 12 Jun 2007, Anthony Martinez wrote: > >>>On Tue, Jun 12, 2007 at 03:10:49AM +0900, Bas van Gils wrote: > >> > >>>As well, reserve the { } form of blocks to one-liners. > >> > >>That's going to depend partly on whether you run across the > >>(relatively rare) case where the precedence difference between {} and > >>do/end actually matters. There are also some interesting ideas on > >>record (see archives) involving blocks with side effects vs. blocks > >>that just calculate. But I can't remember which is supposed to be > >>which :-) > > > >I have yet to see a practical case where the precedence actually came > >into play -- and I suspect that, when I do finally see such a thing, > >readability would benefit from a refactor so that it doesn't come into > >play after all. > > assert_not_nil @enum.find do > # ... a few lines of search code here ... > end > > You need to switch block styles, add some parenthesis, or separate > the two calls. Parentheses sound perfectly reasonable to me. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] Leon Festinger: "A man with a conviction is a hard man to change. Tell him you disagree and he turns away. Show him facts and figures and he questions your sources. Appeal to logic and he fails to see your point."