From: Robert Klemme Date: 2011-10-04T16:18:05+09:00 Subject: Re: [ANN] equal_rights_for_hash 0.0.4 + Ruby proposal On Tue, Oct 4, 2011 at 3:29 AM, Suraj N. Kurapati wrote: > Hello, > > Although Ruby has a rich set of primitive data types and structures, > the Hash seems neglected in the Ruby API in comparison to its peers: > > |           |   Kernel    |  Implicit  |  Explicit  |  NilClass   | > |   Class   |   method    | conversion | conversion | conversion  | > | --------- | ----------- | ---------- | ---------- | ----------- | > |  String   |  String()   |   to_str   |    to_s    |  nil.to_s   | > |  Integer  |  Integer()  |   to_int   |    to_i    |  nil.to_i   | > |   Float   |   Float()   |  to_float  |    to_f    |  nil.to_f   | > |   Array   |   Array()   |   to_ary   |    to_a    |  nil.to_a   | > |   Hash    |   MISSING   |  to_hash   |  MISSING   |   MISSING   | > > To rectify this un-orthogonality, I created a small Ruby library: > >  (gem)  http://rubygems.org/gems/equal_rights_for_hash > >  (code) https://github.com/sunaku/equal_rights_for_hash > >  (docs) http://rubydoc.info/gems/equal_rights_for_hash > > For more information, please see my proposal to incorporate the > above functionality into Ruby's core API on the Ruby Issue Tracker: > >  http://redmine.ruby-lang.org/issues/5008 > > Thanks for your consideration. Despite the discussion in the bug I still do not understand why this is useful. I notice that I have never missed this functionality. It also seems that converting to a Hash is not as straightforward as converting to an Array (because of the pairing of values). What would be gained? Can you provide a number of use cases that demonstrate overall usefulness? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/