Version: v0.7.1 - Beta.  We welcome contributors & feedback.

List.flat

flat($depth = 1) -> list

Description

Convert a mult-dimensional List into a single List with values from all of its sub-Lists.

depth: how many levels of sub-Lists should be flattened.

$mdList = [1, 2, [3, 4]]
$mdList.flat()
//= [1, 2, 3, 4]

$mdList = [1, 2, [3, 4, [5, 6]]]
$mdList.flat()
//= [1, 2, 3, 4, [5, 6]]

$mdList = [1, 2, [3, 4, [5, 6]]]
$mdList.flat(2)
//= [1, 2, 3, 4, 5, 6]

See Also