Skip to content

Instantly share code, notes, and snippets.

@denisdefreyne
Created May 18, 2022 09:41
Show Gist options
  • Save denisdefreyne/e56023b9268d71c24971ed3739bc6afa to your computer and use it in GitHub Desktop.
Save denisdefreyne/e56023b9268d71c24971ed3739bc6afa to your computer and use it in GitHub Desktop.
[4, 2.0, 7, 6.1].grep(Integer) # => [4, 7]
[4, 2.0, 7, 6.1].grep(2..6) # => [4, 2.0]
# Same, but more verbose:
[4, 2.0, 7, 6.1].select { |num| Integer === num }
[4, 2.0, 7, 6.1].select { |num| 2..6 === num }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment