From: Luis D Casillas Date: 2004-03-30T18:54:28+09:00 Subject: Re: Surprise with Hash#new In article , Andrew Johnson wrote: > On Tue, 30 Mar 2004 07:28:40 +0000 (UTC), Luis D Casillas > wrote: > >> PS I ended up not needing that data structure, but after seeing my >> mistake I managed to get the behavior I wanted this way: > > Alternatively, Hash.new can take a block to generate default values: > > @seen = Hash.new {|h,k| h[k] = []} Ah. This is good. -- Luis Casillas Department of Linguistics Stanford University http://www.stanford.edu/~casillas/ "This fence is here for your protection. Do not approach or try to cross, or you will be shot." -- Text of sign on US-installed barbed wire fence around village of Abu Hishma, Iraq. (NY Times, Dec. 7, 2003)