Project

General

Profile

Actions

Feature #13179

closed

Deep Hash Update Method

Added by bettisworth (wurde _) about 7 years ago. Updated over 4 years ago.

Status:
Rejected
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 2 (0 open2 closed)

Related to Ruby master - Feature #19699: Need a way to store values like digClosedActions
Is duplicate of Ruby master - Feature #11747: "bury" feature, similar to 'dig' but opposite Rejectedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0