Short circuit your code, for science!
I think that the topic of short-circuiting is an under-appreciated one. In short, short-circuiting is simply ending an evaluation the instant it becomes false:
1 2 3 |
if(2 < 1 && 1 == 1) { /* stuff */ } if(2 > 1 || 1 == 1) { /* stuff */ } |
In this example, the second condition doesn’t get evaluated in either case. In the first example, the compiler sees that both conditions have to be …