Extending Comparable to clamp values within a range
Daily Coding Tip 006

You may need to ensure a value is within a certain range, and conditional logic is in danger of human error. For instance, do we want to use the < operator or the <= operator? It helps to have an easy way to repeat this process in all cases, so that it works consistently as we expect and reduces the amount of code we need…


