return list from a loop

0
Hi everyone, I'm running several retrieves to get to a list of my domain model. I've already found the desired list, but I want the last list to remain as the return value, but I don't know how to do it. Does anyone have any ideas?
asked
2 answers
1

Hi Ivan,

 

As you have noticed, the variables, lists, etc created in the scope of a loop are disposed of when the loop ends.  To get around this create an empty list outside of the loop and then as the last action in the loop and the retrieved items to the list created outside.  Then once the loop finishes you can return the list in the end action.

 

Hope that helps,

Sam

answered
1

Sam provided the correct answer, but looking at your loop I would use the list operation and take the head of the list and then perform the actions from the loop as you are only looping over 1 item in the list due to the break ativity added in the loop.

answered