Groovy Range objects have subtle but important differences in their methods that can lead to unexpected behavior if misused.
The containsWithinBounds() method only checks if a value falls between the range boundaries, while contains() checks if
the value is actually part of the discrete items in the range. For example, with the range 1.5..3, the value 2 falls within
the bounds but is not actually in the range, since the range contains [1.5, 2.5], incrementing by one from 1.5. Using
containsWithinBounds(2) returns true, but contains(2) correctly returns false.
What is the potential impact?
Using the wrong Range method can cause logic errors in conditional statements, leading to incorrect program behavior.