Robert Klemme
3/19/2006 12:32:00 PM
hoyhoy@gmail.com wrote:
> I'm having a bit of problem using a hash of arrays. It appears that
> nitems are wrong for the individual elements are wrong when I do this:
>
> #!/usr/bin/env ruby
> $:.unshift(File.join('..', 'lib'))
> require 'http-access2'
>
> h = HTTPAccess2::Client.new()
> element = Hash.new([])
You want
element = Hash.new {|h,k| h[k] = []}
Otherwise you'll be adding to the *same* single array instance for *all*
elements.
Kind regards
robert