From: Bill Kelly Date: 2003-12-03T06:32:57+09:00 Subject: Re: Rite, Block locals and Autovivification Hi, From: "John Carter" > > def histogram( enum) > # <--- Implicit hash = Hash.new(0) here > enum.each{|e| hash[e]+=1} # Hash autovivifies. eh? But... somevar[e] ... Why would Ruby assume I wanted a Hash object? That could be an Array, or a String, or....... Do you mean the autovivification would happen only if the variable was actually _named_ 'hash' ? Or am I not understanding your example? > # Since hash autovivified we expect it to be available > # outside the block scope. > hash.keys.sort{|a,b| hash[a]<=>hash[b]}.each do |k| > puts "#{k}\t#{hash[k]}" > end > end Regards, Bill