views:

52

answers:

1

How would I go about removing all empty elements (empty list items) from a nested Hash or YAML file?

Thanks for any advice.

+1  A: 

Use hsh.delete_if. In your specific case, something like: hsh.delete_if { |k, v| v.empty? }

jpemberthy
Thanks. Do you know if that acts recursively or not?
Brian Jordan
Recursive one: `proc = Proc.new { |k, v| v.kind_of?(Hash) ? (v.delete_if(
floatless