Method: Hash#compact
- Defined in:
- lib/fir/patches/hash.rb
#compact ⇒ Object
Returns a copy of self with all blank keys removed.
hash = { name: 'Rob', age: '', title: nil }
hash.compact
# => { name: 'Rob' }
10 11 12 |
# File 'lib/fir/patches/hash.rb', line 10 def compact delete_if { |_, v| v.is_a?(FalseClass) ? false : v.blank? } end |