Skip to main content
Share Your Experience: Take the 2024 Developer Survey
VLAZ's user avatar
VLAZ's user avatar
VLAZ's user avatar
VLAZ
  • Member for 9 years, 7 months
  • Last seen this week
Stats
370
reputation
119k
reached
2
answers
0
questions
Loading…
About

To be, or not to be, that is the question

Translating it into code, we get

theQuestion = 2b || !2b

This returns true for any value of 2b, making the evaluation redundant. We can optimise it by removing the expression and substituting with the result.

theQuestion = true

Badges
1
gold badge
3
silver badges
9
bronze badges
Top tags
20
Score
1
Posts
50
Posts %
20
Score
1
Posts
50
Posts %
4
Score
1
Posts
50
Posts %
4
Score
1
Posts
50
Posts %
4
Score
1
Posts
50
Posts %
Top posts