What is the preferred way to indent cases in a switch?

Posted by neutrino on Stack Overflow See other posts from Stack Overflow or by neutrino
Published on 2010-06-09T12:39:09Z Indexed on 2010/06/09 12:42 UTC
Read the original article Hit count: 226

Filed under:
|
|

Hey there,

As I was writing another switch in Eclipse, I once again came across a rather weird (to me, at least) default indentation, which is applied to 'switch' statements:

switch (i) {
case 1:
    ...
case n:
    ...
}

I tend to prefer another way:

switch (i) {
    case 1:
        ...
    case n:
        ...
}

Which way is more readable and eye-pleasing for you? I'm still not hundred percent determined what's best for me, so I'd like to stick to what's best for other people who would read my code.

BTW, you're free to close this question if this is too subjective. :)

© Stack Overflow or respective owner

Related posts about language-agnostic

Related posts about switch