From: "trans (Thomas Sawyer)" Date: 2012-05-17T00:34:34+09:00 Subject: [ruby-core:45090] [ruby-trunk - Feature #6277] Hash#convert_key Issue #6277 has been updated by trans (Thomas Sawyer). I am going to create a separate issue fro the CRUDify of Hash. After working on the Hashery (http://github.com/rubyworks/hashery) project all this week, it is clear to me that both a key casting proc and a CRUDified Hash class are independently useful. ---------------------------------------- Feature #6277: Hash#convert_key https://bugs.ruby-lang.org/issues/6277#change-26663 Author: trans (Thomas Sawyer) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 =begin Many times a hash with uniform keys is needed (or is at least preferable) for a particular usecase. To this end I propose ((%Hash#convert_key%)). h = {} h.convert_key{ |k| k.to_sym } h['a'] = 1 h.update('b'=>2) h #=> {:a=>1, :b=>2} The idea is similar in concept to ((%#default_proc%)). Others solutions to fill this need have been tried and used, but almost exclusively are in the form of a new class. Most notable is Rails HashWithIndifferentAccess. But ((%#convert_key%)) has much greater flexibility since keys can be converted to anything. =end -- http://bugs.ruby-lang.org/