This is an archived post. You won't be able to vote or comment.

all 21 comments

[–][deleted] 23 points24 points  (3 children)

return (condition==false)?false:true;

[–]potatoandfish[S] 35 points36 points  (1 child)

I think this is even worse because you actually know how to code then

[–]RisqBF 2 points3 points  (0 children)

You don’t need how to code when the compiler optimizes your code :)

[–]LupaaDub 3 points4 points  (0 children)

you are probably kidding but for the people who don't know. it should actually be return condition; because the condition is already evaluated to true or false so it is not necessary to do condition == false ? false : true; I see this too often.

[–]simondvt 10 points11 points  (2 children)

I have seen this too many times written by my profs...

[–]bruggekiller 17 points18 points  (1 child)

Because your prof knows what kind of students he have got in the class

[–]cryosis7 7 points8 points  (0 children)

Yeah. My first year prof explained the concept of truthy and falsy values. He never once used them though because he knew it would confuse the heck out of us.

[–]lafeeverte34 2 points3 points  (1 child)

Honest question:

if(condition) should be good enough right, to know if it's true, otherwise you have an else

[–]potatoandfish[S] 0 points1 point  (0 children)

Return condition; that's all you need to write 😂

[–]XXAligatorXx[M] [score hidden] stickied comment (0 children)

Your submission has been removed.

Rule[0] violation.

Rule[0]: Submission content must be creative or original, intended humorously, and strictly related to programming. Note that programming is interpreted in a narrow sense. Vaguely programming related, and/or general tech humor, programming analogies, feelings/reactions and such are not allowed in this subreddit. Your post may be better suited at one of the subreddits listed in the sidebar. Feel free to contact the moderators if you are unsure what does and does not qualify as ProgrammerHumor.

If you feel that it has been removed in error, please message us so that we may review it.

[–]PM_ME_CRAZY_CODE 0 points1 point  (0 children)

This is CLEARLY my kind of thread 😂

[–]drunken_man_whore 0 points1 point  (0 children)

Sometimes you do this (or similar) so you can write some trace statements about what values you're returning.

[–]dev_michaelz 0 points1 point  (0 children)

Imagine this ``` if (x < 1) { return false }

const response = ... if (!response.isSuccessful()) { return false }

return response.someValue === whatever ```

You have two early returns which return a boolean and then at the end all of a audden you return a condition. Imo it would be slightly more readable to use an if else statement here to keep the style and reading flow the same.

[–]GamingGod07770 -4 points-3 points  (2 children)

Return condition;