Project

General

Profile

Actions

Feature #6276

closed

to_h as explicit conversion to Hash

Added by marcandre (Marc-Andre Lafortune) over 12 years ago. Updated over 12 years ago.

Status:
Closed
Target version:
[ruby-core:44269]

Description

Dear Matz.

We should establish #to_h as the method for explicit conversion to Hash:

  1. Add Hash#to_h: returns self for Hash, or a Hash for subclasses of Hash
  2. Add Struct#to_h: as requested in Feature #4862 under the wrong name
  3. Add OpenStruct#to_h: see Feature #1400

In addition, please consider adding NilClass#to_h.

Even though you are not completely satisfied with NilClass#to_a, I use it very often. If we ever have something equivalent to the splat operator for hashes, the same hesitations will apply to nil.to_h, but I feel it would still bring more good than problems.

Thanks


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #5008: Equal rights for Hash (like Array, String, Integer, Float)Rejectedmatz (Yukihiro Matsumoto)07/10/2011Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0