From: matz@... (Yukihiro Matsumoto) Date: 2000-08-28T12:23:15+09:00 Subject: [ruby-talk:4616] Re: Getting list of regexp matches Hi, In message "[ruby-talk:4614] Re: Getting list of regexp matches" on 00/08/28, Dave Thomas writes: |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. Or try h.fetch('cat'){ stuff } if you're using 1.5.x or later. matz.