Reputation: 1
Is there a better way to type the if statement
if( x > rah || y > rah|| x < 0 || y < 0)
as this looks untidy and perhaps requires more computation than is needed
Upvotes: 0
Views: 84
Reputation: 7057
It may look untidy, you could do this:
if (!between(x, 0, rah) || !between(y, 0, rah))
however, if you're thinking about excessive computations, you should order your conditions in order of likelihood to take advantage of the short-circuit operator ||. This is the only way to actually reduce computations.
Upvotes: 1