Created
May 18, 2022 09:41
-
-
Save denisdefreyne/e56023b9268d71c24971ed3739bc6afa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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