[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

seebs

5/3/2007 4:50:00 PM

In message <463a10df$0$27400$ba4acef3@news.orange.fr>, Josselin writes:
>is it possible to convert easily an Array like this one :
>
>[ nil, "b", nil, nil, nil , "f", "g", nil, nil, "j"]
>
>to an Hash like this one
>
>{ 1 => "b", 5 => "f", 6 => "g", 9 => "j" }
>
>where the key is the position of a value if not nil .. ?

Yes.

-s