I have this
hash = {"foo"=>nil,"bar"=>false,"zoo"=>"monkey","loo"=>"","hoo"=>" "}
I want to reject foo, loo, and hoo
what is the appropriate method to do that?
CodePudding user response:
code
p hash.delete_if{|_,v| v.to_s.strip.empty? }
I have this
hash = {"foo"=>nil,"bar"=>false,"zoo"=>"monkey","loo"=>"","hoo"=>" "}
I want to reject foo, loo, and hoo
what is the appropriate method to do that?
CodePudding user response:
code
p hash.delete_if{|_,v| v.to_s.strip.empty? }