--8323328-1892095387-1135807992 248 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1892095387-1135807992=:9248" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1892095387-1135807992 248 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Sat, 10 Dec 2005, Simon Kröçer wrote: > dblack / wobblini.net wrote: > >>> quantities = Hash.new{|h, k| h[k]=0} >>> ARGF.each{|l| quantities[l.chomp.to_i] += 1} >> >> >> Since you're doing a h[x] += 1 thing, you don't need to do the >> auto-assignment in the block: >> >> quantities = Hash.new(0) >> >> will work fine. > > yes, saw that after pressing the submit button, but as said before > using this form of Hash.new is source of hard to track bugs. [I didn't see this post until just now.] I don't think so. The only problems I've ever seen people encounter with it are from not knowing that: Hash.new([]) will always give you the same object. But once you know that, and therefore know when not to use it, it should be fine. David -- David A. Black dblack / wobblini.net "Ruby for Rails", from Manning Publications, coming April 2006! http://www.manning.com/books/black --8323328-1892095387-1135807992 248-- --8323328-1892095387-1135807992 248--