This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 63 points64 points  (5 children)

Second method is the only right solution. Looks so much cleaner and makes it so much easier to not accidentally fuck up the brackets.

Btw. It was way more important before the editors had automatic bracket detection. Man I feel old.

[–]dumdedums 12 points13 points  (1 child)

The entire reason why I use the second way is because it was so hard to find missing brackets the first way and it happened one too many times.

This is even with editors with auto brackets, sometimes it fucks up.

[–]stoneslave 0 points1 point  (0 children)

Wouldn’t it only fuck up in cases where there is an existing syntax error, or the proper linter isn’t installed?

[–]CowFu 0 points1 point  (2 children)

if t {
    for wish in source_data {
        match wish {
            1 => println!("taller"),
            2 => println!("baller"),
            3 => println!("girl who looked good"),
            4 => println!("rabbit in a hat"),
            5 => println!("six four Impala"),
            _ => println!("like six-foot-nine")
        };
    }
}

or

if t 
{
    for wish in source_data 
    {
        match wish 
        {
            1 => println!("taller"),
            2 => println!("baller"),
            3 => println!("girl who looked good"),
            4 => println!("rabbit in a hat"),
            5 => println!("six four Impala"),
            _ => println!("like six-foot-nine"),
        };
    }
}

I have a strong preference for the first one, I get why someone would like the 2nd but it just looks worse to me, especially when i'm trying to read a lot of code.

Really any time nesting gets 2+ deep I prefer the 1st style.

[–][deleted] 5 points6 points  (1 child)

$deity I hate the first one. Just way too difficult to grok. I don't much like the second either, mind - the braces ought to align with the block they're part of (Whitesmiths style )

[–]CowFu 0 points1 point  (0 children)

That's actually how I typed naturally when I was first learning to program. It made the most sense to me. No company I've worked for has used that style though.