[#23231] What do you think about changing the return value of Kernel#require and Kernel#load to the source encoding of the required file? — =?ISO-8859-15?Q?Wolfgang_N=E1dasi-Donner?= <ed.odanow@...>

Dear Ruby developers and users!

8 messages 2009/04/17

[#23318] [Feature #1408] 0.1.to_r not equal to (1/10) — Heesob Park <redmine@...>

Feature #1408: 0.1.to_r not equal to (1/10)

19 messages 2009/04/26

[ruby-core:23298] Re: [Feature #666](Rejected) Enumerable::to_hash

From: Marc-Andre Lafortune <ruby-core-mailing-list@...>
Date: 2009-04-23 15:08:53 UTC
List: ruby-core #23298
On Thu, Apr 23, 2009 at 9:55 AM, Michael Fellinger
<m.fellinger@gmail.com> wrote:

> Doesn't the new behaviour of Hash::[] solve these cases just as well?

Yes indeed it does, but

1) The new form of Hash[] has yet to be confirmed by Matz (see
http://redmine.ruby-lang.org/issues/show/1385 ).

2) It's not as natural as #to_hash. Don't we usually use instance
methods to convert between types? If you look at conversion between
basic types, you can convert:
Numeric <=> String <=> Symbol
Hash => Array
All these using instance methods. The only arrow missing is from Array
back to Hash!


I'm not sure I understand the rationale behind Hash[] or Array[].
Their existence doesn't hurt but I don't think they are getting much
use. In rails' code, there are no use of Array[] and two of Hash[],
both of which building an array of key-value pairs, then flattening it
before calling Hash[]. They would thus also benefit from the new form
of Hash[] (if it is confirmed as a feature) or, more nicely and
naturally, of a new Array#to_hash. My opinion is that it's much better
to be consistent and have an instance method of Array to get a hash
than to promote the use of an unfamiliar and unpopular use of a class
method.

Thanks

In This Thread