我在Ruby中看過幾次使用_
。Ruby中_有什麼特別的含義,你爲什麼使用它
我不知道在Ruby中有_
的任何特殊含義。但是,爲什麼以及何時使用它?
results = votes.map do |vote|
popu_cost.find(-> {[]}) { |_, cost| cost <= vote }.first
end
或者
votes.each do |e|
key, _ = popu_cost.find { |_, val| e >= val }
results << key if key
end
可能重複[在哪裏以及如何指定\ _(下劃線)變量?](http://stackoverflow.com/questions/9559561/where-and-how-is-the-underscore-variable-specified) –