Marry Jane Marry Jane - 1 year ago 79
Ruby Question

How to increase 1 number value for a Hash?

@participants[id]={nick: nick, points: 0}
=> {"1"=>{:nick=>"Test", :points=>0}

I want to add in points for ID
. I did
but it does not work. How do I make it to add 1 each time?

Answer Source

@participants["1"] is also an hash, so

@participants["1"][:points] += 1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download