Ruby - Hash Element Deleting Conditionally

Introduction

To delete any hash elements whose value is below a certain figure. Here's an example of how to do this:

Demo

x = { "a" => 100, "b" => 20 } 
p x #   w  ww . j av  a2s . c o  m

x.delete_if { |key, value| value < 25 } 
p x

Result

Related Topic