this post was submitted on 28 Oct 2024
505 points (98.3% liked)

Programming Humor

2688 readers
1 users here now

Related Communities [email protected] [email protected] [email protected] [email protected]

Other Programming Communities [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 9 points 1 month ago (1 children)

you can also use XOR operation

return (X || Y) && !(X && Y)
[โ€“] [email protected] 2 points 1 month ago* (last edited 1 month ago)

I was debating on bitwise operations, but decided on super basic if statements which I think the compiler would optimize, happy to see the logical operation form too