Ruby indentantion

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

  • Alfonso, 11/14/2006 04:39 PM:

I have just started with ruby, and something that I have observed
is that most of the code is indented with 2 spaces. Having
programmed some time with C# and python, it’s very strange to me
so few identation. To me 4 spaces is much better to read. Is there
something like a style guide in ruby that says that you should use
2 spaces or is it all right using 4 or 3 spaces? What do you use
in your code?

The number of spaces for indentation depend on at least four factors:

    • the length of an average token
    • wether the token may contain spaces (this is a rare feature but
      some languages actually allow this)
    • the kind of font used to display the code (it can have a narrow,
      square or wide shape which means aspect ratios significantly less
      than, approximately equal to, or significantly larger than one).
    • your perception

In other words: Use the indentation that seems appropriate. I’d only
suggest to stick to a certain indentation to avoid inconsistencies
when merging code. Transforming one indentation into another one is a
Ruby one-liner.

Jupp
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFWvGTrhv7B2zGV08RAnphAKC8RjwVBiSes5HmJJbTl/2QEhQgBACghGN7
N7cBFCYUEL9f5EuPUoAZfpk=
=QoEX
-----END PGP SIGNATURE-----

On Nov 15, 2006, at 1:47 AM, Sebastian Reid wrote:

It seems to me that tabs would make more sense, since they would
allow the reader to set their chosen length of indentation in the
editor.

Using spaces is the only way to guarantee they see the same content
you do.

James Edward G. II

Morton G. escribio’:

Even while I don’t have any problem with my eyes, 2 spaces is also hard
to me. Also, I think I’m going to stay with 3 spaces (a compromiss
between 2 and 4), at least while I don’t get used to the 2 spaces…


LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com