Module: Func::Hash

Included in:
Func
Defined in:
lib/func/hash.rb

Instance Method Summary collapse

Instance Method Details

#hash_fetch(target, *keys) ⇒ Object

Deep fetch values out of a hash.

hash_fetch(target, :a, :b, :c)
target.fetch(:a).fetch(:b).fetch(:c)


8
9
10
11
# File 'lib/func/hash.rb', line 8

def hash_fetch(target, *keys)
  keys.each {|key| target = target.fetch(key) }
  target
end