lib/hash.rb
# works like dig, just writes instead of reads
works like dig, just writes instead of reads
works like dig just writes instead of reads
def dig_assignment(*keys, value)
    last_key = keys.pop
    hash = keys.reduce(self) { |hash, key| hash[key].nil? ? hash[key] = {} : hash[key] }
    hash.has_key?(last_key) ? hash[last_key] += value : hash[last_key] = value
  end
def dig_assignment ( * keys , value ) last_key = keys . pop hash = keys . reduce ( self ) { | hash , key | hash [ key ] . nil? ? hash [ key ] = { } : hash [ key ] } hash . has_key? ( last_key ) ? hash [ last_key ] += value : hash [ last_key ] = value end
works like dig, just writes instead of reads
works like dig just writes instead of reads
# if the last key exists, add the new value to it (ie appends to Array values)
keys
<not_specific>
value
<not_specific>