Flatten a list: Difference between revisions

add Ruby
(add Ruby)
Line 32:
>>> lst
[1, 2, 3, 4, 5, 6, 7, 8]</lang>
 
=={{header|Ruby}}==
<code>flatten</code> is a built-in method of Arrays
<lang ruby>flat = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []].flatten
puts flat.inspect # => [1, 2, 3, 4, 5, 6, 7, 8]</lang>
Anonymous user