I am trying to update my hash's values after subtracting the values by three. For example,
extinct_animals = {
"Passenger Pigeon" => 1914,
"Tasmanian Tiger" => 1936,
"Eastern Hare Wallaby" => 1890,
"Dodo" => 1662,
"Pyrenean Ibex" => 2000,
"West African Black Rhinoceros" => 2011,
"Laysan Crake" => 1923
}
I have this code, which sets the values to subtract three:
extinct_animals.each {|animal, year| puts year - 3}
and the output:
1911
1933
1887
1659
1920
How do I return the entire hash with the keys and new values?
transform_values!would not make it into the Ruby core until eight years after the original question was asked. Also, we've all seen answers offered to questions that were far superior to the answers given to the earlier question. Of course, the great answer could always be added to those given to the duped question, but it won't have much visibility, particularly when, as here, the duped question is ancient. I don't have an answer, but it is a problem.transform_valuesas the second highest voted answer with a score of 61. It would seem that the issue of "visibility" for that answer is non-existent; I don't agree that there is any problem with closing this.