I have a hash with values paired to array-type values like so:
someHash={:key1=>[element1a,element1b],:key2=>[element2a,element2b]}
I tried to iterate over the Hash, access indices and modifying the Hash's array-type values like so:
hash.each_with_index{|(key,array),index|
element1,element2 = array
element1 = "new value"; element2="new value2"
}
hash
However, when I return the hash, the update has not occurred. Is there a hash method like the map! method for arrays I can use (or a different workaround)?
someHash. Your code never references that variable. In Ruby we use snake_case for variables and classes, not camelCase, so usesome_hash, but a more mnemonic name for the variable would be good. The methods available to enumerables are well documented. Please search those first as this question could easily be answered by reading the documentation.