From: dblack@... Date: 2007-01-11T00:07:43+09:00 Subject: Re: [ANN] Elements of Ruby Style Hi -- On Thu, 11 Jan 2007, Christian Neukirchen wrote: > "Justin Bailey" writes: > >> def some_method(arg1, arg) >> raise "Arg1 cannot be nil" if arg1.nil? >> raise "Arg1 must be a number" unless arg1.is_a?(Numeric) >> ... > > This seems to be a style thing I only see in my own code, but which I > consider very helpful when reading code: put two spaces before > statement modifiers. > > I'd have written: > > def some_method(arg1, arg) > raise "Arg1 cannot be nil" if arg1.nil? > raise "Arg1 must be a number" unless arg1.is_a?(Numeric) > ... > > (In this case, I'd probably line them up, too...) > > Since this is the only place I use two spaces in source code, it > slightly stands out and visually seperates the statement from the > modifier, which is especially important if you don't use syntax > highlighting. > > Any comments? I have a bit of a preference for not doing that. It detaches the modifier from the modifiee (?), with a slight tendency to make it look like a new statement is starting. But lining up might counteract that effect. David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)