I have a hash which is say,
hash = {"lock_version"=>4, "exhibition_quality"=>false, "within"=>["FID6", "S2"], "repository"=> {"ref"=>"/repositories/2", "repository"=>{"ref"=>"/repositories/2", "within"=>["FID6", "S2"] } } This hash is been passed through another function. How can I delete from "within"=>["FID6", "S5"] a value with the pattern FID (in this example FID6) without mutating the original hash ash well? This is just a shortened version of the hash but there are other instances where the hash is super long and "within" key value pair appears multiple times. Note: This program is using ruby 2.4
I have been asked to clarify how this question is different from a previous question I asked so this is a little bit of more clarification because I've done more work on it since. This specific key value pair "within"=>["FID6", "S2"], is now appearing deeply nested (the entire hash is about 2 pages long, hence why I didn't copy and paste it). I can't split the hash where the "repository" is because it appears nested in other key values. What I'm asking now is just is there a way to match that within key value no matter now deep it. Thanks everyone for the suggestions.
["FID6", "S2"]is the value ofhash's key"within"and of the key"within"that is a key of a hash that is the value of the key"repository"that is a key ofhash. Is that the only place the key"within"can be found, or, for example, might the key"repository"have a different name or could there be more levels of nested hashes? Note you wrote["FID6", "S5"]where I expect you meant["FID6", "S2"].