Skip to content

Instantly share code, notes, and snippets.

@beakr
Created May 12, 2012 22:36
Show Gist options
  • Save beakr/2669518 to your computer and use it in GitHub Desktop.
Save beakr/2669518 to your computer and use it in GitHub Desktop.
Ruby compact().
# 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