Hash[] $B$N0z?t$,(B Array $B$N>l9g$N?6$kIq$$(B

e$B$H$_$?$G$9!#e(B

Hash[] e$B$N0z?t$,#1$D$NG[Ns$G!“$+$D$=$NMWAG$,$5$i$Ke(B
1e$B8D$+e(B2e$B8D$NMWAG$NG[Nse(B
e$B$N>l9g!”$=$l$r%-!<$HCM$N%Z%"$H$_$J$7$Fe(B(1e$B8D$N>l9g$OCM$Oe(B
nil)e$B!"e(BHash e$B%*%Ve(B
e$B%8%'%/%H$r@8@.$9$k$h$&$G$9!#e(B

ary = [[1,2],[3,4],[5]]
Hash[ary] #=> {5=>nil, 1=>2, 3=>4}

1.8.7 e$B$G$be(B 1.9.2 e$B$G$bF1MM$G$9!#e(B

e$B%^%K%e%"%ke(B http://doc.okkez.net/static/187/class/Hash.html
e$B$K$O$3$NMQK!e(B
e$B$O:$C$F$$$^$;$s$G$7$?!#e(B

e$B$H$$$&$+!“<!$N5-=R$,$”$C$?$N$G$9$,!"e(B

| (4) e$B%-!<$dCM$,G[Ns$@$He(B (2) e$B$de(B (3) e$B$NJ}K!$O;H$($J$$$N$GCOF;$KBeF~$9$k$7$+$J$$e(B
|
| h = Hash.new
| alist = [[1,[“a”]], [2,[“b”]], [3,[“c”]]]
| alist.each {|k,v|
| h[k] = v
| }
| p h
|
| #=> {1=>[“a”], 2=>[“b”], 3=>[“c”]}

e$B:#2s$_$D$1$?J}K!$r;H$&$H!"<!$N$h$&$K4JC1$Ke(B Hash
e$B$r:n@.$G$-$^$9!#e(B

alist = [[1,[“a”]], [2,[“b”]], [3,[“c”]]]
Hash[alist] #=> {1=>[“a”], 2=>[“b”], 3=>[“c”]}

e$B$3$l$,%^%K%e%"%k$K:$C$F$J$$$N$O!“C1$KO3$l$F$$$k$@$1$G$7$g$&$+!#$=$l$He(B
e$B$b2?$+$N;v>p$K$h$j%^%K%e%”%kL$5-:$,A*Br$5$l$?$N$G$7$g$&$+!#e(B

Subversion
e$B$GDI$C$F$_$k$H!"<!$NJQ99$G$3$N5!G=$,DI2C$5$l$?$h$&$G$9!#e(B


r13803 | matz | 2007-11-02 15:30:26 +0900 (e$B6be(B, 02 11e$B7ne(B 2007)
| 8 lines

  • array.c (rb_ary_assoc): check and convert inner arrays (assocs)
    using #to_ary.

  • hash.c (rb_hash_s_create): check and convert argument hash
    using #to_hash.

  • hash.c (rb_hash_s_create): Hash#[] now takes assocs as source of
    hash conversion.

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:41760] Hash[] e$B$N0z?t$,e(B Array
e$B$N>l9g$N?6$kIq$$e(B”
on Tue, 29 Jun 2010 00:28:41 +0900, e$B$H$_$?$^$5$R$me(B
[email protected] writes:

|e$B$3$l$,%^%K%e%"%k$K:$C$F$J$$$N$O!“C1$KO3$l$F$$$k$@$1$G$7$g$&$+!#$=$l$He(B
|e$B$b2?$+$N;v>p$K$h$j%^%K%e%”%kL$5-:$,A*Br$5$l$?$N$G$7$g$&$+!#e(B

e$BO3$l$F$$$k$@$1$@$H;W$$$^$9!#e(B

okkez e$B$G$9!#e(B

2010e$BG/e(B6e$B7ne(B29e$BF|e(B0:28 e$B$H$_$?$^$5$R$me(B
[email protected]:

e$B$3$l$,%^%K%e%"%k$K:$C$F$J$$$N$O!“C1$KO3$l$F$$$k$@$1$G$7$g$&$+!#$=$l$He(B
e$B$b2?$+$N;v>p$K$h$j%^%K%e%”%kL$5-:$,A*Br$5$l$?$N$G$7$g$&$+!#e(B

e$B$^$D$b$H$5$s$N8@$&DL$jO3$l$F$$$k$@$1$G$9!#e(B
e$B$k$j$^%W%m%8%'%/%H$NJ}$G%A%1%C%H$r5/I<$7$F$*$-$^$7$?!#e(B
e$B6a$$Fb$K=q$-$^$9!#e(B

e$B$H$_$?$G$9!#e(B

On Tue, 29 Jun 2010 00:45:27 +0900
Yukihiro M. [email protected] wrote:

e$BO3$l$F$$$k$@$1$@$H;W$$$^$9!#e(B

On Tue, 29 Jun 2010 01:05:54 +0900
okkez [email protected] wrote:

e$B$^$D$b$H$5$s$N8@$&DL$jO3$l$F$$$k$@$1$G$9!#e(B
e$B$k$j$^%W%m%8%'%/%H$NJ}$G%A%1%C%H$r5/I<$7$F$*$-$^$7$?!#e(B
e$B6a$$Fb$K=q$-$^$9!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#e(B

e$B;H$C$F$h$$$b$N$+$I$&$+LB$C$F$?$N$G$9$,!"0B?4$7$F;H$&$3$H$K$7$^$9e(B
:slight_smile:

e$B@.@%$G$9!#e(B

2010e$BG/e(B6e$B7ne(B29e$BF|e(B0:28 e$B$H$_$?$^$5$R$me(B
[email protected]:

e$B%^%K%e%"%ke(B http://doc.okkez.net/static/187/class/Hash.html e$B$K$O$3$NMQK!e(B
e$B$O:$C$F$$$^$;$s$G$7$?!#e(B

e$BBh0l5AE*$K$O!Ve(BRuby e$B$N%^%K%e%“%k!W$H$$$&$N$O!“e(Brdoc
e$B$N$3$H$G$9!#e(B
rdoc e$B$K$O<BAu$HF1DxEY$N5,HO@-$,$”$j!”<BAu$He(B rdoc
e$B$,L7=b$7$?>l9g$O$=$NETEYe(B
e$BE,@Z$J;EMM$,7hDj$5$l!"N><T$KH?1G$5$l$^$9!#e(B

e$B$^$?!“e(Brdoc
e$B$K$O%3%_%C%?$N0U?^$,=q$+$l$F$$$k!J$3$H$,$”$k!KE@$G!“e(B
e$B$”$k;EMM$,$I$NDxEY?d>)$5$l$k$b$N$+$J$I$N>pJs$b4^$`$b$N$G$9!#e(B

e$B$k$j$^$O0J>e$K=R$Y$?$h$&$J$b$N$G$O$J$/!"e(B
e$BC1=c$Ke(B Ruby e$B%f!<%6$N$?$a$N$b$N$G$9!#e(B