# Hash#flatten flattens recursively

e\$B1sF#\$H?=\$7\$^\$9!#e(B

Hash#flatten e\$B\$N%3%a%s%H\$rFI\$`\$H!"\$3\$N%a%=%C%I\$O%G%U%)%k%H\$G\$Oe(B
e\$B:F5"E*\$Ke(B flatten
e\$B\$7\$J\$\$\$H=q\$\$\$F\$"\$k\$N\$G\$9\$,!"<B:]\$K\$O\$9\$k\$h\$&\$G\$9!#e(B

y\$ ./ruby -ve ‘p({1 => “one”, 2 => [2,“two”], 3 => “three”}.flatten)’
ruby 1.9.0 (2008-02-05 revision 15377) [i686-linux]
[1, “one”, 2, 2, “two”, 3, “three”]

e\$B%3%a%s%H\$H<BAu\$N\$I\$A\$i\$,@5\$7\$\$\$N\$G\$7\$g\$&\$+!#e(B

e\$B0J2<\$Oe(B Hash#flatten e\$B\$N%3%a%s%H\$N0zMQ\$G\$9!#e(B

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

In message “Re: [ruby-dev:33603] Hash#flatten flattens recursively”
on Tue, 5 Feb 2008 22:00:45 +0900, “Yusuke ENDOH” [email protected]
writes:

|Hash#flatten e\$B\$N%3%a%s%H\$rFI\$`\$H!"\$3\$N%a%=%C%I\$O%G%U%)%k%H\$G\$Oe(B
|e\$B:F5"E*\$Ke(B flatten e\$B\$7\$J\$\$\$H=q\$\$\$F\$"\$k\$N\$G\$9\$,!"<B:]\$K\$O\$9\$k\$h\$&\$G\$9!#e(B
|
|y\$ ./ruby -ve ‘p({1 => “one”, 2 => [2,“two”], 3 => “three”}.flatten)’
|ruby 1.9.0 (2008-02-05 revision 15377) [i686-linux]
|[1, “one”, 2, 2, “two”, 3, “three”]
|
|e\$B%3%a%s%H\$H<BAu\$N\$I\$A\$i\$,@5\$7\$\$\$N\$G\$7\$g\$&\$+!#e(B

e\$B\$J\$s\$G?)\$\$0c\$C\$F\$k\$N\$+\$<\$s\$<\$s\$o\$+\$i\$J\$\$\$s\$G\$9\$,e(B(e\$B%3%a%s%H\$b<Be(B
e\$BAu\$bN>J};d\$,%A%’%C%/%\$%s\$7\$F\$\$\$ke(B)e\$B!";H\$\$>!<j\$r9M\$(\$k\$H%3%a%s%He(B
e\$BM%@h\$NJ}\$,NI\$\$\$h\$&\$J5\$\$,\$7\$F\$-\$^\$7\$?!#e(B

e\$BD>\$7\$^\$9!#e(B