Robert Feldt <feldt / ce.chalmers.se> writes:

> Anyone knows of a Ruby coding standard or at least some recommendations on
> how to write Ruby code that is easily readable? Has some consensus
> evolved?

Have a look at some of the library code. If you feel it's readable,
then copy its style ;-)

I personally use the One True Editor, and Ruby comes with an emacs
mode that lays things out the way _I_ like out of the box (except:
Matz- that last 'do' change means iterators no longer lay out
properly)

One style thing I have evolved towards is attempting to be consistent
in my choice of do/end or {,} for iterators. I've come down in favor
of using {} for single line iterators and do/end for multiline ones:

   a.each { |l| puts l}

   b.each do |line|
     if line.length > 45
       # ...
     else
       # ...
     end
     gurgle(line)
   end

To me, the 'end' in the multiline form echos the 'end' used in ifs,
whiles, and the like.

           end
         end
       end

looks more pleasing than

           end
         }
       end


Regards


Dave