Hi,
I have the following code where i want to display the message "Hello World" only once in a loop . what condition i should write?
a!localVariables(
a!forEach( items: {1,2,3,4}, expression: { concat("Hello "," World")
}
))
Discussion posts and replies are publicly visible
In order to display a message once in a loop, first decide the condition for displaying a message. Then implement the condition inside the loop.
For example, if I want to display the Hello World when I reach second iteration or item, follow the below code snippet
a!forEach( items: { 1, 2, 3, 4 }, expression: { if( fv!item = 2, concat("Hello ", " World"), null ) })
To avoid null values in the results:
reject( fn!isnull, a!forEach( items: { 1, 2, 3, 4 }, expression: { if( fv!item = 2, concat("Hello ", " World"), null ) } ))
Hi there,
I'm not sure if I got your requirement, but if you just want the unique values after a loop, you can try something similar to that:
a!localVariables( local!a: a!forEach( items: { 1, 2, 3, 4 }, expression: { concat("Hello ", " World") } ), union(local!a, local!a) )
Regards,
Acacio B
Thank you
Thanks it works