Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

flatMap

flatMap(Array<T>, (item: T, index: Number) → Array<R>): Array<R>

Maps an array of items using the specified callback and applies flatten to the resulting array.

Transform

        
     
1
2
3
4
%dw 2.0
output application/json
---
users: ['john', 'peter', 'matt'] flatMap([$$ as String, $])
Output

        
     
1
2
3
4
5
6
7
8
9
10
{
   'users': [
     '0',
     'john',
     '1',
     'peter',
     '2',
     'matt'
   ]
 }
flatMap(Null, (Nothing, Nothing) → Boolean): Null

Helper function that allows flatMap to work with null values.