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

A function named newProdCode needs to be defined that accepts two input parameters, an integer value for ItemID and a string value for productCategory, and returns a new product code.

What is the correct DataWeave code to define the newProdCode function?

A.

B.

C.

D.

    Correct Answer:

    The correct answer is A. In DataWeave, to define a function, you use the `fun` keyword followed by the function name and equals sign `=`. The arrow `->` is used for lambda functions and not for defining named functions. Therefore, the correct syntax to define the `newProdCode` function that accepts an integer value for ItemID and a string value for productCategory is correctly illustrated in option A. The other options incorrectly use `->` which cannot be used in this context.

Discussion
chengl

A is correct. https://docs.mulesoft.com/mule-runtime/4.3/dataweave-functions

Zumo

Yes, you are correct. C gives a dataweave error. -> cannot be used. Most people will think because if '?' A is wrong. But A is the Correct Answer.

Swoody77

The answer is A, as others have put, the -> symbols cannot be used in a function like this, only =.

xasihih752

You're right, as a general rule, lambda functions cannot be named

senthil_Kumar_Murugan

A is the correct Answer we neeed to use "=" in function

thamizhanda

The answer is A, as '->' symbol is used in option C which is not a valid syntax in a function and it should be '='

ExamDev

A is correct

ExamDev

A is correct.

AntarJalil

Yep it is A. The only issue I saw on option A is that ""productCategory" is defined as "string" instead of "String" ( 's' instead of Capital S). However, if I also define a custom type (type string = String ) , it works fine . I just tried . so it is A the right answer .

Pavankumar142

A is correct

Nazarii

A Correct

MULEMADDY

A is correct

lelebc10baar

A CORRECT ANS - syntax is right here

Carolinek

A is correct

frediepulgoso

A is correct

mohammad_jani

A is the correct answer

maeda

fun myFunction(param1, param2, ...) = <code to execute> its = cannot ->