if (conditional) {
}
or
if (conditional)
{
}
if (conditional) {
}
or
if (conditional)
{
}
Other urls found in this thread:
google.github.io
google.github.io
twitter.com
the occupation of lesser men
The second one.
>work
#2 is in the coding standard.
>home
>>only program at home when moving a game or interviewing.
>>>modding, use either or both. Who gives a shit.
>>>interview, try and look up companies std, default to the Google std if it can't be found. #1 for the most part.
#1 is the coding standard in everything but C#.
Nobody gives a shit what google has to say.
Whatever the coding standard says.
Either is readable, but I personally prefer the first, it is more compact.
If I am the one who makes the standard, the curly brace should only be on a separate line if it severs a purpose, like when you initialize a class.
Ex:
example::example() :
_value_a(),
_value_b()
{
//stuff
}
looks a lot better than
example::example() :
_value_a(),
_value_b() {
//stuff
}
or
example::example() : _value_a(), _value_b() {
//stuff
}
sauce?
> a ? b : c
Out of the way plebians, patrician coming through.
Ternary if supported.
Otherwise use what the language itself suggest using.
If the language itself has no style guidelines,
fall back to the first one posted.
>Google style guides
Not when they recommend this for HTML: google.github.io
>
The second one is compulsory where you are rated by your "output" and "productivity".
if (conditional) {
//stuff
} else { // save more v-space
/other stuff
}
>pajeet metrics
Leave.
I found the elder god tier:
if(conditional){ some_shit_here(); other_shit();}
>not using higher order conditionals
if (!(err = (a > b) ? func1(a) : func2(b)))
Literally doesn't matter.
I'd fire any "programmer" daring to submit this to review.
What's wrong with it?
It kills many birds in one stone and would be written in 5 + 10 lines if it was written the retard way like you suggest.
>using if
>not ternary operator
plebs
you guys dont know anything
// simple program to test if 1 + 1 = 2 is true
#include
enum Booleans : bool { T = true, F = false};
void isTrue(Booleans statement, Booleans* output) {
if (statement == Booleans::T) {
*output = Booleans::T;
} else { if (statement == Booleans::F) {
*output = Booleans::F;
}
}
}
using number = int;
number main(int argc, char * * argv) {
char stringFalse[6] = {'F','A','L','S','E','\0'};
char stringTrue[5] = {'T','R','U','E','\0'};
Booleans temp;
Booleans statement;
if (1 + 1 == 2) {
statement = Booleans::T;
} else {
if (1 + 1 != 2) {
statement = Booleans::F;
}
}
isTrue(statement, &temp);
if (temp == Booleans::T) {
std::cout
Everything, and if you can't see it, you do not belong in the field.
yeah ok neet boy
>posts unreadable unmaintainable prone-to-bugs code
first one.
> hard to read
> hard to debug
> hard to handle errors
> not flexible
did I miss anything?
Improper use of the ternary operator and the implication that both functions return 0 as success.
These
these manga guides are so trash
i didn't expect any rigor, but the information density is SO LOW that they resort to dumping entire pages worth of material without the cute drawings so the reader can catch up because they can't into pacing.
if (conditional)
{
}
>Not giving tab to the brackets
Shiggty
if conditional is True:
#stuff
#1
The latter looks like two separate blocks. In the first one it basically reads "here is the condition, start the block. It just reads better
The only thing that jumps out to me as being weird is the fact that the ending brace has its own line while the first one doesn't
That actually makes sense
>{
Into the trash it goes.
4 lines vs 1 line in pure C
>when you realize it doesn't matter because it compiles to the same assembly
Why don't you write all your code on one single line then?
First
Second is only for functions, methods, classes, or objects.
> Implying I don't
The one that doesn't mindlessly waste lines.
I'm writing, not scrolling down a stupid facebook-esque site that never ends.
>inconsistent brace spacing
>Either is readable, but I personally prefer the first, it is more compact.
compact is less readable you dingus
I do.
Fuck off GNU
Personally I use second for class/method/function definitions and first for everything else. Makes it extra clear.
This guy gets it.
First one, because it works better with code folding and doesn't waste vertical space, though by that argument
if (condition) {
foo();
bar();
baz(); }
would be the best.
Personally though, I think what would be the most aesthetic is
if condition do
foo()
bar()
baz()
end do
// simple program to test if 1 + 1 = 2 is true
#include
#include
enum Booleans : bool { T = true, F = false};
void isTrue(Booleans statement, Booleans* output) {
if (statement == Booleans::T) {
*output = Booleans::T;
} else { if (statement == Booleans::F) {
*output = Booleans::F;
}
}
}
using number = int;
namespace c_plus_plus_standard_namespace = std;
using Booleans_to_c_string_map_type = c_plus_plus_standard_namespace::map;
number main(number argc, char * * argv) {
char stringFalse[6] = {'F','A','L','S','E','\0'};
char stringTrue[5] = {'T','R','U','E','\0'};
Booleans temp;
Booleans statement;
Booleans_to_c_string_map_type boolean_to_c_string_map;
boolean_to_c_string_map[Booleans::T] = stringTrue;
boolean_to_c_string_map[Booleans::F] = stringFalse;
if (1 + 1 == 2) {
statement = Booleans::T;
} else {
if (1 + 1 != 2) {
statement = Booleans::F;
}
}
isTrue(statement, &temp);
if (temp == Booleans::T) {
c_plus_plus_standard_namespace::cout