From: "marcandre (Marc-Andre Lafortune)" <ruby-core@...>
Date: 2012-04-11T11:19:29+09:00
Subject: [ruby-core:44283] [ruby-trunk - Feature #6276] to_h as explicit conversion to Hash


Issue #6276 has been updated by marcandre (Marc-Andre Lafortune).


Great.

I'll do it with pleasure, expect a slight delay as I'm going in vacation for 10 days.

Thanks
----------------------------------------
Feature #6276: to_h as explicit conversion to Hash
https://bugs.ruby-lang.org/issues/6276#change-25821

Author: marcandre (Marc-Andre Lafortune)
Status: Assigned
Priority: Normal
Assignee: marcandre (Marc-Andre Lafortune)
Category: core
Target version: 2.0.0


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


-- 
http://bugs.ruby-lang.org/