Equal_rights_for_hash 0.0.4 + Ruby proposal

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) equal_rights_for_hash | RubyGems.org | your community gem host

(code) GitHub - sunaku/equal_rights_for_hash: Adds Kernel#Hash() and generic #to_h() methods.

(docs) File: README — Documentation for equal_rights_for_hash (0.0.4)

For more information, please see my proposal to incorporate the
above functionality into Ruby’s core API on the Ruby Issue Tracker:

Feature #5008: Equal rights for Hash (like Array, String, Integer, Float) - Ruby master - Ruby Issue Tracking System

Thanks for your consideration.

On Tue, Oct 4, 2011 at 3:29 AM, Suraj N. Kurapati [email protected]
wrote:

| Float | Float() | to_float | to_f | nil.to_f |

For more information, please see my proposal to incorporate the
above functionality into Ruby’s core API on the Ruby Issue Tracker:

Feature #5008: Equal rights for Hash (like Array, String, Integer, Float) - Ruby master - Ruby Issue Tracking System

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