Hash#to_hashがHashを返さない

xibbar$B$3$HF#2,$G$9!#(B

$BI=Bj$O$A$g$C$T$j$"$*$j5$L#$G$9$,!"(B
Ruby$B$N(BHash#to_hash$B$O(BHash$B$rJV$5$:$K(Bself$B$rJV$7$^$9!#(B
Hash$B$N$^$^;[email protected]$C$?$i$$$$$N$G$9$,!"(B
$B$3$l$r7Q>5$9$k$H!"(B
% irb
irb(main):001:0> class MyHash<Hash;end
=> nil
irb(main):002:0> myhash=MyHash.new
=> {}
irb(main):003:0> myhash.to_hash
=> {}
irb(main):004:0> myhash.to_hash.class
=> MyHash
$B$H$J$C$F$7$^$$$^$9!#(B
$B$3$l!"(BArray#to_a$B$d(BString#[email protected]$H(B
Array$B$H(BString$B$r$=$l$>$lJV$7$^$9!#(B

Hash#to_hash$B$O(BHash$B$rJV$7$?$[$&$,$$$$$N$G$O$J$$$G$7$g$&$+!)(B
$B8=>u!“7Q>5$7$?(BHash$B$+$i([email protected]$k$?$a$K$O(B
Hash[myhash]$B$H$d$k$N$,@52r$N$h$&$G!”(B
$B$3$l$O$3$l$GN"5;$K6a$$$H;W$$$^$7$?!#(B

At Wed, 17 Jul 2013 08:26:03 +0900,
xibbar wrote:

=> {}
irb(main):004:0> myhash.to_hash.class
=> MyHash
$B$H$J$C$F$7$^$$$^$9!#(B
$B$3$l!"(BArray#to_a$B$d(BString#[email protected]$H(B
Array$B$H(BString$B$r$=$l$>$lJV$7$^$9!#(B

Hash#to_hash$B$O(BHash$B$rJV$7$?$[$&$,$$$$$N$G$O$J$$$G$7$g$&$+!)(B
$B8=>u!“7Q>5$7$?(BHash$B$+$i([email protected]$k$?$a$K$O(B
Hash[myhash]$B$H$d$k$N$,@52r$N$h$&$G!”(B
$B$3$l$O$3$l$GN"5;$K6a$$$H;W$$$^$7$?!#(B

Array#to_a $B$KAjEv$9$k$N$O(B Hash#to_h
$B$G$9!#$3$$$D$O7Q>5$7$F$b(BHash$B$rJV$7(B
$B$^$9$h!#(Bmyhash.to_h $B$G(BOK$B$N$O$:!#(B

to_str/to_ary/to_hash $B$H%U%k%M!<%`$NJQ49%a%=%C%I$O!“K\Ev$K$=$l$>$l(B
String/Array/Hash
$B$K0EL[$NJQ49$b$7$F$[$7$$$H$$$&[email protected]$1!W!”$=$l$>$l(B
$B$N%/%i%9$N%$%s%9%?%s%9$rJV$9$h$&$K(B($B:F(B)$BDj5A$9$Y$7$H$$$&$N$,7h$^$j$G$9!#(B
$B!J(BRuby$B$G$O(B Klass.try_convert, C API$B$G$O(B
rb_convert_type()$BEy$G0EL[$K;H$o(B
$B$l$k$?$a!K(B

$B=>$C$F!"I,MW$J$i7Q>5$7$?>e$G(B to_hash
$B$r:FDj5A$9$Y$-!JC1=c$J%1!<%9$J$i(B
alias to_hash to_h$B!K$H$$$&$N$,[email protected]$H;W$$$^$9!#(B

[email protected]!"(B Array#to_a/to_ary $B$O$=$&$J$C$F$$$k$1$I(B String#to_s/to_str
$B$O$=$&(B
$B$G$O$J$$$h$&$G$9!#$*$=$i$/!"(B String $B$r7Q>5$9$k$N$O(B String
$B$N3HD%$7$?2?(B
$B$+$r:n$j$?$$%1!<%9$J$N$G(B String
$B$X$N<+F0JQ49$OK>$^$l$k$3$H$,<[email protected]$,!"(B
Array/Hash
$B$O%3%s%F%J$G$"$j!"3HD%$H$$$&$h$j$OFbJq$9$k$h$j3Z$J$N$G7Q>5$9(B
$B$k$H$$$&%1!<%9$,B?$$$N$G<+F0JQ49$OI,$:$7$bK>$^$l$J$$$H$$$&$3$H$J$N$+$J(B
$B$H$$$&$N$,;d$N?dB,$G$9!#(B