From: Dave Thomas Date: 2000-08-28T08:20:14+09:00 Subject: [ruby-talk:4614] Re: Getting list of regexp matches Brian Fundakowski Feldman writes: > Hash.new may take an argument that specifies the default value for > hash members. To do it with empty arrays, for example: >... > Hope it helps! 'fraid not. Currently the default parameter is evaluated just once, so all entries will default to having the same empty array. h = Hash.new(Array.new) h['cat'] << 'hello' h['dog'] << 'goodbye' puts h['cat'].inspect #=> ["hello", "goodbye"] However, there's some talk of a new syntax: h = Hash.new { stuff } Where the block will be evaluated to create missing elements. Regards Dave