Sha256: 64575cecf79f5ab6f9e45cd339804395d32af6a234a22f0a7fecaac7ce03b98c

Contents?: true

Size: 322 Bytes

Versions: 10

Compression:

Stored size: 322 Bytes

Contents

class Hash

  # Iterate over hash updating just the values.
  #
  #   h = {:a=>1, :b=>2}
  #   h.update_values{ |v| v+1 }
  #   h  #=> { a:=>2, :b=>3 }
  #
  # CREDIT: Trans

  def update_values #:yield:
    if block_given?
      each{ |k,v| store(k, yield(v)) }
    else
      to_enum(:update_values)
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

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