From: e@... Date: 2014-10-13T20:47:40+00:00 Subject: [ruby-core:65686] [ruby-trunk - Feature #8246] [Closed] Hash#traverse Issue #8246 has been updated by Zachary Scott. Status changed from Open to Closed Priority changed from Low to Normal Yeah, sorry, this is a duplicate of #5531 with just a different method name ---------------------------------------- Feature #8246: Hash#traverse https://bugs.ruby-lang.org/issues/8246#change-49417 * Author: Zachary Scott * Status: Closed * Priority: Normal * Assignee: 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 ---Files-------------------------------- 275.patch (3.05 KB) -- https://bugs.ruby-lang.org/