Sha256: 0b6c9c5ea265534187b51b5e4d7f83bb6a607027afa5b68c8368ec536071c4f5

Contents?: true

Size: 222 Bytes

Versions: 9

Compression:

Stored size: 222 Bytes

Contents

class Hash

  # Instantiate a new hash with a default
  # value determined by the block.
  # 
  # Hash.new_with { [] } 
  #
  # CREDIT: Pit Capitan

  def self.new_with #:yield:
    new { |h, k| h[k] = yield }
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/hash/new_with.rb
facets-2.8.3 lib/core/facets/hash/new_with.rb
facets-2.8.2 lib/core/facets/hash/new_with.rb
facets-2.8.1 lib/core/facets/hash/new_with.rb
facets-2.8.0 lib/core/facets/hash/new_with.rb
facets-2.7.0 lib/core/facets/hash/new_with.rb
facets-2.6.0 lib/core/facets/hash/new_with.rb
facets-2.5.1 lib/core/facets/hash/new_with.rb
facets-2.5.2 lib/core/facets/hash/new_with.rb