Created
March 28, 2014 10:57
-
-
Save ericdke/9830115 to your computer and use it in GitHub Desktop.
Get hash content except some keys (filter hash)
This file contains 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
def filter(hsh, *keys) | |
hsh.reject { |k, _| keys.include? k } | |
end | |
# Usage | |
histogram = { | |
monday: 5, | |
tuesday: 7, | |
wednesday: 10, | |
thursday: 18, | |
friday: 7, | |
saturday: 2, | |
sunday: 0 | |
} | |
filter(histogram, :saturday, :sunday) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment