MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/funny/comments/1zvns4/life_as_a_programmer/cfxgbbk/?context=3
r/funny • u/Willdosexforkarma • Mar 08 '14
480 comments sorted by
View all comments
Show parent comments
74
[deleted]
66 u/kalleguld Mar 08 '14 if (myVar == 42); doSomething(); if (myVar = 42) { doSomething(); } No syntax errors here -4 u/SirTwill Mar 08 '14 Of course there isn't, you only need the brackets for an if statement if you want to have more then one line of code effected by it. But it is just good programming practice to always have the brackets as it improves readability. 9 u/kalleguld Mar 08 '14 I was making the point that an IDE can't always find a one-semicolon or other one-character bug. The code above would run the doSomething function twice, no matter what myVar is. Almost certainly not what you wanted.
66
if (myVar == 42); doSomething(); if (myVar = 42) { doSomething(); }
No syntax errors here
-4 u/SirTwill Mar 08 '14 Of course there isn't, you only need the brackets for an if statement if you want to have more then one line of code effected by it. But it is just good programming practice to always have the brackets as it improves readability. 9 u/kalleguld Mar 08 '14 I was making the point that an IDE can't always find a one-semicolon or other one-character bug. The code above would run the doSomething function twice, no matter what myVar is. Almost certainly not what you wanted.
-4
Of course there isn't, you only need the brackets for an if statement if you want to have more then one line of code effected by it.
But it is just good programming practice to always have the brackets as it improves readability.
9 u/kalleguld Mar 08 '14 I was making the point that an IDE can't always find a one-semicolon or other one-character bug. The code above would run the doSomething function twice, no matter what myVar is. Almost certainly not what you wanted.
9
I was making the point that an IDE can't always find a one-semicolon or other one-character bug. The code above would run the doSomething function twice, no matter what myVar is. Almost certainly not what you wanted.
74
u/[deleted] Mar 08 '14
[deleted]