Sha256: df0dd65d1f00c1153f3f74edfc604789a15c0bbb452423caa3c99912533b956c

Contents?: true

Size: 242 Bytes

Versions: 8

Compression:

Stored size: 242 Bytes

Contents

# -*- coding: utf-8 -*-

class Hash
  # Destructive elimination of nil, like Array#compact!
  def compact!
    reject! do |k, v|
      v.nil?
    end
  end

  # Intuitive, see the source.
  def compact
    dup.tap {|i| i.compact! }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tengine_support-1.2.2 lib/tengine/support/core_ext/hash/compact.rb
tengine_support-1.2.1 lib/tengine/support/core_ext/hash/compact.rb
tengine_support-1.2.0 lib/tengine/support/core_ext/hash/compact.rb
tengine_support-1.1.0 lib/tengine/support/core_ext/hash/compact.rb
tengine_support-0.3.27 lib/tengine/support/core_ext/hash/compact.rb
tengine_support-0.3.26 lib/tengine/support/core_ext/hash/compact.rb
tengine_support-0.3.25 lib/tengine/support/core_ext/hash/compact.rb
tengine_support-0.3.24 lib/tengine/support/core_ext/hash/compact.rb