From: Robert Dober Date: 2007-06-13T04:49:01+09:00 Subject: Re: a matter of style On 6/12/07, dblack@wobblini.net wrote: > Hi -- > > On Wed, 13 Jun 2007, Robert Dober wrote: > > >> Almost. puts adds "\n" unless it's already there. So these are > >> equivalent: > >> > >> print "hello\n" > >> puts "hello\n" > > Right but do you remember when I stupidly changed your code from > > puts a > > to > > puts a.join("\n") > > > > So this is another difference between print and puts, puts prints the > > content of an array seperated by newlines. print does no such thing of > > course. > > > >> particular, please have mercy and don't leave the parens out in method > >> signatures. Things like this: > >> > >> def a b, c, d = 1 > >> > >> read very strangely, at least to my eyes. > > I love it, I *really* read it better like this. But I guess the > > community rather puts parens :( and if you want to comply listen to > > David. > > Let us just have a look at the Ruby core as David suggests below > > Another little test: > > $ ruby -e 'puts > ARGF.select{|f| f =~ /^\s*def\s\w+\s+\w+/}.size' $(ruby -e 'puts > Dir["**/*.rb"]') > 120 > > $ ruby -e 'puts > ARGF.select{|f| f =~ /^\s*def\s\w+\s+\w+/}.size' $(ruby -e 'puts > Dir["**/*.rb"].reject {|fn| fn =~ /rexml/} ') > 9 > > :-) I think Sean is skewing the graph :- I love that guy... ;) Seriously it would be stupid to advice a newby into a personal style that is way off mainstream and I did not. But I will not put parens around my defs because I feel that if Ruby gives me this possibility and I like it I should use it. Now when it comes to working in teams the whole story changes again... most important thing being a *consistent* style. By adopting a style close to mainstream that can be achieved easier.... That is why I feel that this discussion is important. > > David > > -- > * Books: > RAILS ROUTING (new! http://safari.awprofessional.com/9780321509246) > RUBY FOR RAILS (http://www.manning.com/black) > * Ruby/Rails training > & consulting: Ruby Power and Light, LLC (http://www.rubypal.com) > Cheers Robert -- Books: Wait a minute why is nobody publishing me ;) Are you reading this Tim? Robert