How would I go about removing all empty elements (empty list items) from a nested Hash or YAML file?
If you're using Ruby 2.4+, you can call compact and compact!
compact
compact!
h = { a: 1, b: false, c: nil } h.compact! #=> { a: 1, b: false }
https://ruby-doc.org/core-2.4.0/Hash.html#method-i-compact-21