Method: Hash#put!

Defined in:
lib/casual_support/hash/putbang.rb

#put!(key, value) ⇒ Hash

Associates key with value. Similar to Hash#[]=, but returns the Hash instead of the value. Faster than Hash#merge! for single updates in a loop.

Examples:

cache = id_list.reduce({}) do |hash, id|
  hash.put!(id, find_by_id(id))
end

Parameters:

  • key
  • value

Returns:



15
16
17
18
# File 'lib/casual_support/hash/putbang.rb', line 15

def put!(key, value)
  self[key] = value
  self
end