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.