I am trying to change the hash value if the key exists in the hash. I have an operating algorithm to change it to the correct value, the only problem is that it changes all the values โโin the hash, and not just the one I want. How to change only certain values โโin a hash?
Have I tried the hash.has_key method? (key) and it still changes all my values
if @hash.has_key?(k) @hash.select {|k,v| v.price = (v.price/100)} else print "Key not found" end
Cen92 source share