Flowdock
method

compact_blank

Importance_1
v6.1.3.1 - Show latest stable - 0 notes - Class: Enumerable
compact_blank() public

Returns a new Array without the blank items. Uses Object#blank? for determining if an item is blank.

[1, "", nil, 2, " ", [], {}, false, true].compact_blank
# =>  [1, 2, true]

Set.new([nil, "", 1, 2])
# => [2, 1] (or [1, 2])

When called on a Hash, returns a new Hash without the blank values.

{ a: "", b: 1, c: nil, d: [], e: false, f: true }.compact_blank
#=> { b: 1, f: true }
Show source
Register or log in to add new notes.