[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: file.png (14 KB, 674x208)
14 KB
14 KB PNG
its something i've been doing lately. It feels pretty clean & it saves a lot of vertical space which is nice but is also feels a bit taboo.
It becomes slighly niggerlicious when you have many statements in the body like
if(x){++x; y = 3; if(x%2) coninue; break;}
but i still think its elegant-ish and if it isn't then you can always break it up into multiple lines at that point.

Also since im making a whole thread feel free to post other taboo coding styles that are actually nice.
>>
>>107703965
>pretty clean
>that are actually nice.
shit taste
>>
>>107703965
Single line conditionals is forgivable, no spaces after if and while isn't.
>>
File: file.png (50 KB, 987x172)
50 KB
50 KB PNG
>>107703965
yeah I do this. I always put braces though. helps when I occasionally end up having to add lines to the branch
>>
as long as it compiles and has some comments i do not fucking care
>>
>>107703965
I use it sometimes, but I have a strict rule: only if the body is 1 (ONE) statement. Avoids wasting 2 or 3 lines (depending on brace style) for 1-statement functions.

On anything longer, having a newline separating statements feels cleaner and also the overhead of a couple of lines allocated to braces is no longer significant
>>
shit taste and shit code.
if (foo)
DoFoo();
if (bar)
DoBar();
while (!elements.empty()) {
sum += elements.front();
elements.pop();
}
while (sum)
if (sum % 2)
print(sum);
if (baz)
if (sum > 30)
print(print);



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.