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.