Re:Reading the Ruby Source to Understand Rails Idiosyncrasies
by norswap on Saturday July 20, 2013 @05:15PM
(#6076608)
`cover?` uses the comparison operators to check if the value is within the range. `include?`, on the other hand, will behave like `cover?` only if the range values are "numeric". If they aren't, it will iterate through the range to see if it contains the value. This is possible because range values are required to implement the `succ` method which gives the next value.
[ Parent
| on HN ]
There are no comments on this comment yet.