Reputation: 658
Hi i am working on a Migration project from Spring to Mule .
In Java we have small function like
private String[] getPurpose(loanPurpose){
String purpose[] = new String[2];
if ("REFINANCE".equalsIgnoreCase(loanPurpose)) {
purpose[0] = "Refinance";
purpose[1] = "Cash-Out";
return purpose;
}
return null;
}
In Mule i am writing it like below .
fun getPurpose(data) =
if(upper("PURCHASE") == data)
// how i can assign the values in string array and return
Upvotes: 0
Views: 952
Reputation: 4303
It should work fine in studio as well. Probably the way the if value is represented could be throwing it off.. Try with the following:
%dw 2.0
output application/json
fun getPurpose(data) =
if(upper("PURCHASE") == data) (["Refinance", "Cash-Out"]) else if (1 == 2) "abc" else "nothing"
---
getPurpose("PURCHASE")
Output:
[
"Refinance",
"Cash-Out"
]
Upvotes: 1
Reputation: 25837
[ "Refinance"," Cash-out"]
Just create the array literal with the strings as the last value of the function. I'n this case the is the value of the true branch of if
.
Upvotes: 2