If i assign "list B = list A", should all further changes on list A also be applied to list B, since these values are passed by reference?
Hi José,
It depends if the list is being passed by parameter in the same module (or assigned in the same module) or in different modules.
I will include some screenshots with an example.
In a module called Test_A, I've created an action called "Test_ListByValue", with the following code:
As you can see, we assign a value "ByValue" in a record with the same structure as the list and we append it to the List.
After that, we reference this action in the Test_B module and include it in a local action of the module called "Test_List":
In this action, you can see the difference behaviors when the action is inside the module and outside the module:
List copied by value
As you can see, after calling the "Test_ListByValue" my list is still empty. This means that another list was created and has it's own data.
List copied by Reference
In the next action, we have the same code as the "Test_ListByValue" present in the Test_A module (only the assigned text is different) but now this action is in the same module as the action that calls it (Test_B module)
In the Debug, continuing the execution of this action, we can see that the List is not empty anymore:
Hope I could help you.
Kind regards,
Miguel Sousa
Hi,
We have many list function except List Duplicate all passed by ref.
Thanks!
I just deleted Chritiano's answer, as it is plain wrong. When assigning a list to another list, they reference the same list items, so adding something to one list is reflected via the other. When passing as parameter, see Miguel's excellent answer.
Also, just came to mind, be careful with actually assuming an assign refers to the same list: this is _only_ the case when the lists have identical types. If one is a List of Records instead of a List of Structures, a silent conversion happens, and they're two different lists. Also, if both are List of different Structures, but with the same attributes (or compatible attributes), a silent conversion happens.