From: 7stud -- Date: 2007-09-03T15:31:46+09:00 Subject: Re: Hash.new with a block? Robert Klemme wrote: > $ ruby -e 'h=Hash.new {|h,k| h[k]=[]}; set_trace_func(lambda {|*a| p > a}); h[1]<<2' > ["line", "-e", 1, nil, #, false] > ["c-call", "-e", 1, :[], #, Hash] > ["c-call", "-e", 1, :default, #, Hash] > ["c-call", "-e", 1, :call, #, Proc] > ["line", "-e", 1, nil, #, false] > ["c-call", "-e", 1, :[]=, #, Hash] > ["c-return", "-e", 1, :[]=, #, Hash] > ["c-return", "-e", 1, :call, #, Proc] > ["c-return", "-e", 1, :default, #, Hash] > ["c-return", "-e", 1, :[], #, Hash] > ["c-call", "-e", 1, :<<, #, Array] > ["c-return", "-e", 1, :<<, #, Array] > > I believe there's also some explanation in the documentation. > I don't know what that output means. I have also looked up Hash.new in the book "Programming Ruby (2nd ed)" and it doesn't mention anything about the particulars. The same documentation is displayed when I type: $ri Hash.new ...If a block is specified, it will be called with the hash object and the key, and should return the default value. It is the block's responsibility to store the value in the hash if required. So, as far as I can tell, the Ruby documentation doesn't help with my question. -- Posted via http://www.ruby-forum.com/.