Last active
June 8, 2020 02:06
-
-
Save euccas/6724ff6a18858cb01080a222c2157249 to your computer and use it in GitHub Desktop.
remove empty hash element
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 remove_empty_hash_element(h) | |
if h and h.length>0 | |
h.each do |k,v| | |
h.delete(k) if v.respond_to?('empty?') and v.empty? | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment