method

compact!

v2_6_3 - Show latest stable - Class: Hash
compact!()
public

Removes all nil values from the hash. Returns nil if no changes were made, otherwise returns the hash.

h = { a: 1, b: false, c: nil }
h.compact!     #=> { a: 1, b: false }