Answer the question
In order to leave comments, you need to log in
How to parse hashes in Ruby?
Repl
example .
How to walk through the entire hash with nestings in Ruby, preferably without recursions.
In the example from Repl.it, who has show equal to true , he is taken.
You also need to look at the show value of children .
But if the object has a child, then it is excluded from the selection. But his chil's are not.
For example, there is such a hash.
{
"aaa"=>{"show"=>true},
"bbb"=>{"show"=>false},
"ccc"=>{
"show"=>true,
"child"=>{
"child_1"=>{"show"=>true},
"child_2"=>{"show"=>false}
}
},
"ddd"=>{"show"=>false}
}
{:aaa=>123, :child_1=>123}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question