From: Chad Perrin Date: 2007-06-12T19:45:08+09:00 Subject: Re: a matter of style On Tue, Jun 12, 2007 at 03:39:47AM +0900, Anthony Martinez wrote: > > From what I've been led to understand, method names consisting of > multiple words should be named_with_underscores, not namedWithCamelcase. > > `puts' is the same as `print "something\n"' > > Parens can be omitted if it doesn't confuse the parser (or the reader) > > As well, reserve the { } form of blocks to one-liners. > > Taking these into account, instead of writing (from > http://www.van-gils.org/~bas/bridgehands/deal.rb): > > bg.suits.each{ |suit| > cards = bg.north.cardsOfSuit(suit) > print " #{bg.sortCards(cards)} \n" > } > > write something like > > bg.suits.each do |suit| > cards = bg.north.cards_of_suit suit > puts " #{bg.sort_cards(cards)} " > end > > Then again, these are highly subjective views, ones that I've absorbed > from reading other people's ruby and getting into arguments with friends > :) Take them with a grain of salt, as I'm not a Ruby expert and thus I > might be wrong. Your suggestions are pretty much canonical Ruby style, at first glance at least. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] Ben Franklin: "As we enjoy great Advantages from the Inventions of others we should be glad of an Opportunity to serve others by any Invention of ours, and this we should do freely and generously."