Project

General

Profile

Feature #13179

Deep Hash Update Method

Added by bettisworth (wurde _) over 3 years ago. Updated about 1 year ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:<unknown>]

Description

I came across a scenario where I needed the ability to update a deeply nested hash (Rails i18n yaml files). This seemed like something that would exist naturally in the DSL of ruby, but I could only find dig() method which only retrieves values if they exist. 24 hours later I wrote a update_deep_hash method (I wouldn't wish this type of recursive coding on anyone else within the Ruby community).

Attached is the solution I hacked together. My question is if we can have a Hash.dig() method which reaches into a deep hash can we expand on this to include update methods of similar nature?


Files

update_deep_hash.rb (2.26 KB) update_deep_hash.rb bettisworth (wurde _), 02/01/2017 06:45 PM

Related issues

Is duplicate of Ruby master - Feature #11747: "bury" feature, similar to 'dig' but opposite Rejectedmatz (Yukihiro Matsumoto)Actions

Also available in: Atom PDF