From: Adam Prescott Date: 2011-05-26T04:09:47+09:00 Subject: [ruby-core:36473] Re: [Ruby 1.9 - Feature #4772] Hash#add_keys --90e6ba6e8d90a2d7de04a41e7293 Content-Type: text/plain; charset=UTF-8 On Wed, May 25, 2011 at 3:20 PM, Joey Zhou wrote: > 1) hash = Hash.new {|h,k| k.succ } > 2) hash = Hash.new {|h,k| h[k] = k.succ } > > 1) and 2) are different, 2) will actually create any key/value pair the > hash ever seen a key, but 1) will not, it needs an assignment. > Ah I see, I missed the lack of assignment in the block to Hash.new. I suppose potentially there's some confusion that might come up when using Hash#add_keys and Hash.new given that one block is being used for both purposes? --90e6ba6e8d90a2d7de04a41e7293 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Ah I see, I missed the lack of assignment in the bloc= k to Hash.new. I suppose potentially there's some confusion that might = come up when using Hash#add_keys and Hash.new given that one block is being= used for both purposes?
--90e6ba6e8d90a2d7de04a41e7293--