From: Robert Dober Date: 2009-04-28T16:58:26+09:00 Subject: Re: Block Style On Tue, Apr 28, 2009 at 12:05 AM, James Gray wrote: > On Apr 27, 2009, at 3:25 PM, Robert Klemme wrote: > >> On 27.04.2009 19:11, Robert Dober wrote: >>> >>> (I guess that it is {} for one liners and do end otherwise than) >> >> One liner and multi liner is actually exclusive, which cannot be said of >> return value and side effects.  Maybe my sticking to the syntactical >> convention is the reason why I never bother to think about which rules to >> use.  James, maybe that can ease your "pain" as well?  :-) > > It's definitely easier, but it can lead to less pretty code too, like: ...and being easier it just does not convey any additional information. I adapted my style because I thought - and still think - that providing the information of side effect is of value to the reader of the code. I am aware that being used to the style is also very valuable to the reader, but that is a long, interesting and complicated matter, which, if not OT is Super Topic in the mathematical sense of superset. That said I should probable stick to {} if there is no side effect to the block (1), thus indicating functional style and to do end for anything else, because if the return value of the block is used or not should actually be well documented. Which is worth yet another discussion. That would, e.g give, to cite myself ;) _, *args = whatever.split.sort_by{ .... } inject{ } # while inject do ... end should raise an alarm bell and each.do |x| puts x end # sorry if this example is too sophisticated ;) (1) Updating closed in locals considering a side effect or not? Cheers Robert > >  whatevery.map do |e| >    # multiple lines of calculation here... >  end.find { ... } > > That's one reason why I was looking into the other option. > > James Edward Gray II > > -- Si tu veux construire un bateau ... Ne rassemble pas des hommes pour aller chercher du bois, préparer des outils, répartir les tâches, alléger le travail… mais enseigne aux gens la nostalgie de l’infini de la mer. If you want to build a ship, don’t herd people together to collect wood and don’t assign them tasks and work, but rather teach them to long for the endless immensity of the sea. -- Antoine de Saint-Exupéry