# Hash#flatten

**URL:** <https://www.ruby-forum.com/t/hash-flatten/134511>\
**Category:** Development\
**Created:** [April 11, 2008, 4:06pm UTC](https://www.ruby-forum.com/t/hash-flatten/134511 "2008-04-11T16:06:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8edcca/32.png) [@okkez](https://www.ruby-forum.com/u/okkez)\
**Post date:** [April 11, 2008, 4:06pm UTC](https://www.ruby-forum.com/t/hash-flatten/134511/1 "2008-04-11T16:06:48Z")

</div>

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

e$B%j%U%!%l%s%9%^%K%e%"%k$N:n6H$r$7$F$$$F5$$E$$$?$N$G$9$,!"e(BHash#flatten  
e$B$NF0:n$,%3%a%s%H$He(B  
e$B0[$J$C$F$$$k$h$&$G$9!#%3!\<%I$NF0$-$K%3%a%s%H$r9g$o$;$k%Q%C%A$r=q$$$F$\_$^$7$?!#e(B

# Index: hash.c

— hash.c (revision 15977)  
+++ hash.c (working copy)  
@@ -1677,8 +1677,9 @@

- _level_ argument determines the level of recursion to flatten.
- 
- 

```
a = {1=> "one", 2 => [2,"two"], 3 => "three"}

```

- 
  - 

```
a.flatten # => [1, "one", 2, [2, "two"], 3, "three"]

```

- 
  - 

```
a.flatten(1) # => [1, "one", 2, [2, "two"], 3, "three"]

```

  - 

```
a.flatten(2) # => [1, "one", 2, 2, "two", 3, "three"]

```

- 
  - 

```
a.flatten # => [1, "one", 2, 2, "two", 3, "three"]

```

\*/

static VALUE

---

<div class="post-metadata">

**Author:** ![okkez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8edcca/32.png) [@okkez](https://www.ruby-forum.com/u/okkez)\
**Post date:** [April 11, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/hash-flatten/134511/2 "2008-04-11T16:35:07Z")

</div>

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

e$B2?$+$b$N$9$4$$4\*0c$$$r$7$F$$$?$_$?$$$G$9!#e(B  
e$B$9$_$^$;$s$,!"0J2\<$N%Q%C%A$O\<h$j2\<$2$^$9!#e(B

# e$B\<+J,$G$b2?$r8+4V0c$($?$N$+$o$+$i$J$$e(Borz

08/04/11 e$B$Ke(B okkez[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) e$B$5$s$O=q$-$^$7$?e(B:
