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

With ruby 3.4 (prior to that `_1` should be used instead of `it`):

    (0..10).select{it.even?}


Also not that the result is `[0, 2, 4, 6, 8, 10]`, unlike the behavior of Python which exclude the value explicitely passed in parameter from the represented range.




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

Search: