4 ms·
One uses a loop and one doesn't? Not sure if there's so much to get out of this post.
by ahawkins 13y ago
One uses a loop and one doesn't? Not sure if there's so much to get out of this post.
- norswap 13y ago`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.