[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Array#to_hash

Yukihiro Matsumoto

2/11/2009 3:27:00 PM

Hi,

In message "Re: Array#to_hash"
on Thu, 12 Feb 2009 00:19:10 +0900, Trans <transfire@gmail.com> writes:

|Would any problems arise from extending Array with this?

Nothing I can think of, except that I have never wanted such
conversion from array to hash in my 16 year Ruby programming. ;-)

matz.

2 Answers

Robert Dober

2/11/2009 8:21:00 PM

0

On Wed, Feb 11, 2009 at 4:26 PM, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
> Hi,
>
> In message "Re: Array#to_hash"
> on Thu, 12 Feb 2009 00:19:10 +0900, Trans <transfire@gmail.com> writes:
>
> |Would any problems arise from extending Array with this?
>
> Nothing I can think of, except that I have never wanted such
> conversion from array to hash in my 16 year Ruby programming. ;-)
>
Yeah the usecase somehow eludes me too. Did you mean
{:a => 0, :b => 1, :c =>2 }
by any chance?

Robert

Trans

2/11/2009 11:13:00 PM

0



On Feb 11, 10:26=A0am, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:
> Hi,
>
> In message "Re: Array#to_hash"
> =A0 =A0 on Thu, 12 Feb 2009 00:19:10 +0900, Trans <transf...@gmail.com> w=
rites:
>
> |Would any problems arise from extending Array with this?
>
> Nothing I can think of, except that I have never wanted such
> conversion from array to hash in my 16 year Ruby programming. ;-)

True enough. And maybe there never will be. There are many words in
the dictionary I never use too. Still, they have definitions, and if
one were to define Array#to_hash, that would seem like the clear
meaning. (I use #to_h for the more useful conversions).

Thanks,
T.