Module: Hash::Compact

Included in:
Hash
Defined in:
lib/vex/base/hash/compact.rb

Defined Under Namespace

Modules: Etest

Instance Method Summary collapse

Instance Method Details

#compactObject



2
3
4
# File 'lib/vex/base/hash/compact.rb', line 2

def compact
  dup.compact!
end

#compact!Object



6
7
8
9
10
11
# File 'lib/vex/base/hash/compact.rb', line 6

def compact!
  empty = []
  each { |k,v| empty << k if v.nil? }
  empty.each do |k| delete(k) end
  self
end