Off Topic > Off Topic
Programming Megathread
Timestamp:
--- Quote from: Tudoreleu on December 29, 2016, 06:40:45 AM ---this {
..
}
or that
{
..
}
--- End quote ---
i use both
do people make a big deal about this? it's basically the same thing just different format
SUSHI:
--- Quote from: Timestamp on December 29, 2016, 02:46:46 PM ---do people make a big deal about this? it's basically the same thing just different format
--- End quote ---
Yes. It's pretty ridiculous, huh?
--- Quote from: Nickelob Ultra on December 29, 2016, 02:41:58 PM ---I can get the semicolons thing but what the forget is wrong with braces on the same line? You can't tell me that this
--- Code: ---int main() {
do_stuff();
self_destruct();
if (1 < 0) {
cry();
} else {
be_happy();
}
}
--- End code ---
doesn't look better and saves lines as opposed to this disgusting waste of lines
--- End quote ---
--- Code: ---main()
{
(1 < 0) ? cry() : be_happy();
}
--- End code ---
:panda:
/dev/sr0:
--- Quote from: SUSHI on December 29, 2016, 03:04:45 PM ---
--- Code: ---main()
{
(1 < 0) ? cry() : be_happy();
}
--- End code ---
--- End quote ---
wooaaahh whats that
McJob:
--- Quote from: /dev/sr0 on December 29, 2016, 03:28:45 PM ---wooaaahh whats that
--- End quote ---
The ternary operator.
--- Code: ---condition ? true expression : false expression;
--- End code ---
If you only need to do one thing in either case, it's much cleaner than having multiple lines for an if/else.
And in the debate on braces; braces deserve their own lines. SO much easier to read and manage code when the braces denote code blocks.
Headcrab Zombie:
When I first started programming i did braces on their own line simply because that's what the example code used. Now I continue doing it because it's a habit and I haven't cared enough to change.
These days I just use the automatic formatting that visual studio applies, it would be a pain to try to fight it. I'm sure it can be disabled, but I don't really care enough to bother.