class Array

def compact_blank!

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

Uses Object#blank? for determining if an item is blank.
Removes all blank elements from the +Array+ in place and returns self.
def compact_blank!
  # use delete_if rather than reject! because it always returns self even if nothing changed
  delete_if(&:blank?)
end