lib/hm.rb
def compact
    Algo.visit_all(@hash) do |at, path, val|
      Algo.delete(at, path.last) if val.nil?
    end
  end
# Removes all `nil` values, including nested structures.
#
# @example
#   order = {items: [{title: "Beef", price: nil}, nil, {title: "Potato", price: 8.2}], total: 26.2}
#   Hm(order).compact.to_h
#   # => {:items=>[{:title=>"Beef"}, {:title=>"Potato", :price=>8.2}], :total=>26.2}
#
# @return [self]
Removes all `nil` values, including nested structures.
Removes all ` nil ` values including nested structures .
def compact
    Algo.visit_all(@hash) do |at, path, val|
      Algo.delete(at, path.last) if val.nil?
    end
  end
def compact Algo . visit_all ( @hash ) do | at , path , val | Algo . delete ( at , path . last ) if val . nil? end end
Removes all `nil` values, including nested structures.
Removes all ` nil ` values including nested structures .
None
self
example
None