From: Rodrigo Rosenfeld Rosas Date: 2011-05-25T23:04:26+09:00 Subject: [ruby-core:36462] Re: [Ruby 1.9 - Feature #4772] Hash#add_keys Em 25-05-2011 10:54, Yusuke ENDOH escreveu: > Hello, > > 2011/5/25 Rodrigo Rosenfeld Rosas: >> Actually, as already noticed here, this could be just: >> >> ['a', 'b', 'c'].each {|k| hash[k]} # You don't need to assign to it. > > The assignment is needed. > > hash = Hash.new {|h,k| k + k.succ} > ["a","b","c"].each {|k| hash[k] } > > p hash #=> {}<- LOOK! > > > This feature might be useful to use a hash as a set... > I'm not sure though. Yes, I didn't read the documentation and believed on Adam statement, sorry :) I think that "add_keys" makes the code more readable than the current alternative. Or maybe "add_keys_with_default_value" :)