Concatenating an array of arrays in Coffeescript

Posted by user380572 on Stack Overflow See other posts from Stack Overflow or by user380572
Published on 2011-01-08T00:24:29Z Indexed on 2011/01/08 0:54 UTC
Read the original article Hit count: 141

Filed under:
|

Hi everyone, I'm trying to find an elegant way in Coffeescript to merge an array of arrays, so that [[1,2,3],[4,5,6],[7,8,9]] ==> [1,2,3,4,5,6,7,8,9].

As you might imagine, I need this because I'm generating arrays from a function in a "for in" construct and need to concatenate the resulting nested array:

result = (generate_array(x) for x in arr)

Is there an elegant way to handle this? Thanks for any pointers!

© Stack Overflow or respective owner

Related posts about arrays

Related posts about coffeescript