+ 41
Which is your style of coding?
Note for loop only contains 1 statement. i saw some people including me uses braces{} Even for 1 statement. Is it good practice? ---------------------------------------- Style 1: for(i=0; i<9; i++) s += i; ----------------------------------------- Style 2: for(i=0; i<9; i++){ s += i; } ------------------------------------------- Style 3: for(i=0; i<9; i++) { s += i; } --------------------------------------- My style is 2 in all case😅 post your style for single and multiple😆 Also tell which is best?
73 Antworten
+ 25
2.
+ 23
For very short statements, I just nest them directly into increment section, if it doesn't affect the result.
for (i = 0; i < 9; s += i++);
It's not a good practice, but lol. Highly influenced by SL challenges wts material.
+ 17
style_2: all case
for (i=0, i<9,i++){
s+=1;
}
+ 15
1 or 2.
+ 14
2.
+ 13
2.
+ 12
my style is 2
+ 11
5:
for(i=9;i--;)
s+=i;
+ 11
#2
+ 11
I tend to write long codes so after I understand them well enough I reduce whitespace and line breaks... ie this style.
for (i=0;i<99;i++){console.log(i);}
otherwise style 2 almost always
+ 11
mostly 1 and 2
+ 11
Am in love with 2
+ 10
I just try to squeeze as much as possible, unless I am noob at that language.
Ao mostly I look like:
for (i=0;i<9,i++){do stuff}
+ 9
1 and 3
+ 9
@JeMa=@Hatsy Rei {^_^}
+ 8
I do
for(;;) ...;
Another thing I do is
if(){
...
}else
if(){
...
}else {
...
}
+ 8
None because in python we dont use brackets 😁
+ 8
Visual Studio has the default 3, so it's the one I usually use so I like the 2
+ 8
@Prashant i think @XiangShuai is from US so he don't know hindi, try some translators or better learn English😊
+ 8
2