Q: Using delete_if to delete single value of hash not the entire hash RUBY I have a array
array_hash = [
  {
    "array_value" => 1,
    "other_values" => "whatever",
    "inner_value" => [
      {"iwantthis" => "forFirst"},
      {"iwantthis2" => "forFirst2"},
      {"iwantthis3" => "forFirst3"}
    ]
  },
  {
    "array_value" => 2,
    "other_values" => "whatever2",
    "inner_value" => [
      {"iwantthis" => "forSecond"},
      {"iwantthis2" => "forSecond2"},
      {"iwantthis3" => "forSecond3"}
    ]
  },
]

I want to delete inner value or pop it out (i prefer pop).
So my output should be this:
array_hash = [
  {
    "array_value" => 1,
    "other_values" => "whatever"
  },
  {
    "array_value" => 2,
    "other_values" => "whatever2"
  },
]

I tried delete_if
array_hash.delete_if{|a| a['inner_value'] }

But it deletes all data in the array. Is there any solution?

A: try this:
array_hash.map{ |a| {'array_value' => a['array_value'], 'other_values' => a['other_values'] }}


A: You are telling ruby to delete all hashes that have a key called inner_value. That explains why the array remains empty.
What you should probably do instead is:
array_hash.each { |x| x.delete 'inner_value' }

which means: for each hash in this array, erase the inner_value key.

A: Well I found it,
array_hash_popped = array_hash.map{ |a| a.delete('inner_value') }

This will pop (because I want pop as stated in the question) the inner_value out and hence inner value will be reduced/deleted from array_hash.
