I want to generate nested hash from string. Input: key: a.b.c value: true Output: {:a=>{:b=>{:c=>true}}}
I have the following method from the stackoverflow: Generate nested hashes from strings and deep merging in ruby
hash = {}
"one.two.three".split('.').reduce(hash) { |h,m| h[m] = {} }
puts hash #=> {"one"=>{"two"=>{"three"=>{}}}}
This generates an empty value for the last object and I need to assign a value to it through method itself without specifying keys name.
Any idea on how to achieve this?