jeudi 12 mars 2015

check if hash value of specific key contains specific value ruby

I have hash with key and multiple values. now I have to check if specific value exists in that multiple values or not.


The stucture of my hash is like this...



@allinfo[hour_idx].push([ "id" => w.id, "cat" => w.cat, "value" => w.value])


Now I want to check if id already exist for the allinfo[hour_idx] key. I am trying to use if(@allinfo.has_value?(w.id) but it is not working, which I guess becoz I am custom object of multiple values.


My main objective is not to have mulitple id's in values for specific key. I hope I am clear what I except...Thanks


Thanks


Aucun commentaire:

Enregistrer un commentaire