From: "headius (Charles Nutter)" Date: 2013-04-12T05:00:52+09:00 Subject: [ruby-core:54197] [ruby-trunk - Feature #8246] Hash#traverse Issue #8246 has been updated by headius (Charles Nutter). As a feature that affects all Ruby implementations, this should probably move to CommonRuby: https://bugs.ruby-lang.org/projects/common-ruby ---------------------------------------- Feature #8246: Hash#traverse https://bugs.ruby-lang.org/issues/8246#change-38475 Author: zzak (Zachary Scott) Status: Open Priority: Low Assignee: matz (Yukihiro Matsumoto) Category: core Target version: =begin From (()) Traverses the given levels of a hash and returns the value associated with the last key provided. Allows for concise access for deeply nested hashes - often encountered with dealing with external restful apis. (({hash = { level1: { level2: { level3: 3 } } }})) (({hash.traverse :level1, :level2, :level3 #=> 3})) Also supports a default value block if the value is nil or the key is not found. (({hash.traverse(:level1, :level2, :non_existent_key) { 5 } #=> 5})) =end -- http://bugs.ruby-lang.org/