r/ProgrammerHumor • • Jul 10 '18

What people think coding is...

Post image
21.1k Upvotes

398 comments sorted by

View all comments

Show parent comments

23

u/thestonedturtle Jul 10 '18

A good IDE would warn you about assignment inside an if condition

9

u/Albi_ze_RacistDragon Jul 11 '18

‘if (a == b)’ vs ‘if (a === b)’ would probably be a better example

1

u/thestonedturtle Jul 11 '18

Now that is annoying lol

2

u/[deleted] Jul 11 '18

Sometimes you don't have a choice of what ide/language you have to work on, and the more unfamiliar you are with the languages (especially the tricky ones), the easier it is to make these mistakes.

But it's what we do, so c'est la vie 😁

1

u/[deleted] Jul 11 '18

What about C?

int c;
if ((c = getchar()) != EOF) {
    ...
}

1

u/thestonedturtle Jul 11 '18

Theres also a comparison in that condition though.

1

u/[deleted] Jul 11 '18

Yeah but it's not only legal, it's encouraged in K&R's C book, and they literally wrote the language.

2

u/thestonedturtle Jul 11 '18

I meant that since there is still a comparison the IDE should see that as a valid if condition, if there is no comparison it should warn you.

1

u/[deleted] Jul 11 '18

Ooooh ok I see

1

u/UnchainedMundane Jul 11 '18

The compiler will warn you if the assignment is not individually bracketed.

i.e. if (c = getchar()) still throws a compiler warning

-7

u/kodedemonmikalhanson Jul 10 '18

depends how old you are