C
C#•3y ago
vargonian

Should I use && and || operators at the end of a line or beginning? [Answered]

if (a b c) { } vs. if (a b c) { } Which is the more accepted standard? I just want to stop questioning myself every time I encounter this. Thanks.
10 Replies
Becquerel
Becquerel•3y ago
use three ` to start and end blocks of formatted code i personally think that if you have boolean conditions long enough to span multiple lines... they should be split up, one way or another boolean logic is hard enough to parse as-is
Angius
Angius•3y ago
$code
MODiX
MODiX•3y ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat If your code is too long, post it to: https://paste.mod.gg/
mtreit
mtreit•3y ago
Oh man, this question. I never know what to do for this - I think I tend to write code both ways and I have never decided which is easier to read.
Auger
Auger•3y ago
The former
if (conditional
|| another
&& oneMore)
if (conditional
|| another
&& oneMore)
Angius
Angius•3y ago
I tend to want to align things, so
if (
abc &&
def &&
ghi
)
if (
abc &&
def &&
ghi
)
instead of
if (
abc
&& def
&& ghi
)
if (
abc
&& def
&& ghi
)
Although fairly sure I don't actually have a consistent style there and use both lol
333fred
333fred•3y ago
I do this. I find it far more readable
vargonian
vargonianOP•3y ago
Alright, it seems like it's still debatable, I won't feel guilty for choosing one over the other. 🙂 Thank you for your feedback. And thanks for the tips for posting code; I wasn't sure it would work in this discussion thread format.
333fred
333fred•3y ago
You chose a good topic name Drew the flies like honey 😄
Accord
Accord•3y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server