Exam MCD - Level 1 All QuestionsBrowse all questions from this exam
Question 56

What does the zip operator do in DataWeave?

    Correct Answer: D

    The zip operator in DataWeave takes two lists (arrays) and merges them into a single list by creating pairs of elements from the same index in each list. For every element at index `i` in the first list, it pairs it with the element at index `i` in the second list, resulting in a list of these pairs.

Discussion
AquawormOption: D

The first sub-array in the output array contains the first indices of the input sub-arrays. The second index contains the second indices of the inputs, the third contains the third indices, and so on for every case where there are the same number of indices in the arrays. https://docs.mulesoft.com/dataweave/2.4/dw-core-functions-zip

d_ngnrOption: D

Sample: %dw 2.0 output application/json --- [1, 2, 3] zip ["A", "B", "C"] Output: [ [1, "A"], [2, "B"], [3, "C"] ]

ExamDevOption: D

ZIP function merges elements from two arrays into an array of arrays.

kampatraOption: D

it's bit tricky: As per document: Merges elements from two arrays into an array of arrays. here it's mentioned merge into a single list. seems correct but not sure.