Skip to content

Instantly share code, notes, and snippets.

@paddyzab
Created February 23, 2016 08:08
Show Gist options
  • Save paddyzab/6dd5e76d3333894b2efd to your computer and use it in GitHub Desktop.
Save paddyzab/6dd5e76d3333894b2efd to your computer and use it in GitHub Desktop.
Two helper methods to improve semantics of range comparison.
private boolean isOutsideRange(int i, int lowerBound, int upperBound) {
return (i < lowerBound || upperBound < i);
}
private boolean isInsideRange(int i, int lowerBound, int upperBound) {
return (i < lowerBound && upperBound < i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment