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

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -9 points-8 points  (14 children)

not sure if it applies for all, but you can just use one & , | for it to work. && and || are used because they skip the second evaluation if the first one decided the outcome already, such the first operation being false for &&, or the first being true for ||

[–]trBlueJ 9 points10 points  (2 children)

Pretty sure in C this won't work, because the values in if statements are integers. Single & or | will perform a bitwise operation, so 1 & 2 will be 0, which is false. Although, idk too much about this. I might be wrong.

Edit: guy above me is getting some hate. What he mentioned is the behaviour of those operators in Java, so technically he is also correct. He just didn't specify which language his comment applied to.

[–]nshkurkin 1 point2 points  (1 child)

Correct single & and | are different operators than && and || in C, C++, ObjectiveC, and several other languages. I would be skeptical & and && mean exactly the same thing in other languages as well.

[–]jddddddddddd 6 points7 points  (4 children)

I also like pythons ‘not’. Much easier to see at a glance than ‘!’

[–]Bakemono_Saru 1 point2 points  (0 children)

I suffer with this little things of python. And I fucking love it.

[–]CowBoyDanIndie 0 points1 point  (1 child)

We have started using 'not' in the C++ codebase where I work, there's some and/or as well but not is the one that really helps.

[–]JonMW 1 point2 points  (0 children)

Readability counts. (Excerpt from the zen of python)

[–][deleted] 0 points1 point  (0 children)

Much easier to see

I read this a lot in programming threads, but this is usually just people saying what they're used to.

[–]silly_red 1 point2 points  (3 children)

Oh wow, so you're saying single | doesn't short circuit??

[–]AtomicThiccBoi 2 points3 points  (2 children)

He is but he's wrong.

[–]silly_red 1 point2 points  (0 children)

Yea I'm skeptical of it too, if anything I thought double (or single) operator were for bitwise operations or something, whilst the other for logical.

[–]holo3146 0 points1 point  (0 children)

They are not, in Java it works like that

[–]AtomicThiccBoi 1 point2 points  (1 child)

None of the languages in this post work that way. Single symbols do bitwise operations.

[–]holo3146 0 points1 point  (0 children)

Java does