Created
May 12, 2012 22:36
-
-
Save beakr/2669518 to your computer and use it in GitHub Desktop.
Ruby compact().
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
# It's good to remove any nil values, thus cleaning up an array when in use. | |
[1, 2, nil 3, nil].compact | |
#=> [1, 2, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment