From: "David A. Black" Date: 2009-08-10T15:32:44+09:00 Subject: Re: How to define doubles: Array-to-hash Hi -- On Mon, 10 Aug 2009, Bertram Scharpf wrote: > Hi, > > Am Montag, 10. Aug 2009, 08:17:42 +0900 schrieb 7stud --: >> Bertram Scharpf wrote: >>> h = Hash.new { |h,k| h[k] = 0 } >> >> h = Hash.new { |h,k| h[k] = 0 } >> >> is equivalent to: >> >> h = Hash.new(0) > > Arrgh. Of course. Actually they're not equivalent. >> h = Hash.new(0) => {} >> h[1] => 0 >> h => {} >> h = Hash.new {|h,k| h[k] = 0 } => {} >> h[1] => 0 >> h => {1=>0} David -- David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com Q: What's the best way to get a really solid knowledge of Ruby? A: Come to our Ruby training in Edison, New Jersey, September 14-17! Instructors: David A. Black and Erik Kastner More info and registration: http://rubyurl.com/vmzN