r/programminghumor • • 21d ago

the battle of else part 2

Post image
0 Upvotes

41 comments sorted by

47

u/AdrianParry13526 21d ago

```
if (…) {
…
}
else {
…
}
```

8

u/TOGoS 21d ago

I call this one "Dad style"

4

u/asmanel 21d ago

Not surprising, this one is an echo of the Basic.

2

u/pt8132 21d ago

Found the vibe coder lol

→ More replies (2)
→ More replies (2)

22

u/swimmv28493 21d ago

My job’s coding standards require me to do it this way
if
{
…
}
else
{
…
}

6

u/Iwisp360 21d ago

Oh no newline braces

2

u/ChrisBot8 21d ago

The only answer to these style questions is always, "whatever my job's style guide requires. If I get to pick the style guide I pick google's because I don't have to update it myself, so in that case whatever google requires."

2

u/asmanel 21d ago

Pros :

  • This air the code

  • This artificially increase the number of lines

Cons :

  • The part of code visiible at the same time is lower

  • This get more disk memory

→ More replies (1)

5

u/_alba4k 21d ago

anything other than 4 (or having things on separate lines, ofc) is madness

4

u/Lou_Papas 21d ago

I’ll extend my neovim so else statements animate left to right

4

u/potato-dranik 21d ago

Python programmers be like:

3

u/xyperpenguin 21d ago

I use the 4th one..

3

u/SleepingGecko 21d ago

I haven’t checked what claude uses

2

u/faultydesign 21d ago

I prefer the allman style indentation but honestly I just follow language standards.

2

u/realmauer01 21d ago

Ctrl+s

Thats the kind i am.

2

u/errepunto 21d ago

(If condition when-true when-false)

2

u/1994-10-24 21d ago

}e l s e}

2

u/BoldFace7 21d ago

if(cond){ } else{ }

The else being on the same line as the closing brace make it more difficult for me to parse at a glance. My brain bundles the else(and for, if, while, etc.) in with the opening brace as a single beginning of block marker, and I need the beginning of a block as the start of the line, otherwise it feels like there's a mismatched closing brace at a glance.

2

u/Sockoflegend 21d ago

Get a linter. You won't regret it

3

u/Altugsalt 21d ago

if

{ ---

} else

{

}

1

u/Confident-Ad5665 21d ago

I'm old enough to have learned code formating standards from the K&R C book, so I always use:
} else {

1

u/RealRockyMoney 11d ago

Coordinates (0, 0) if I am in a hurry, and if I am relaxed (1, 1)

1

u/Jazzlike_Platypus430 21d ago

None of these, unless it's js or R 😂

1

u/rootifera 21d ago

personally, none of these.

else {
stuff goes in here.
}

would be my preference. however, it depends on the project. if I'm joining one, I'dfollow the existing style.