Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One uses a loop and one doesn't? Not sure if there's so much to get out of this post.


`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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: