Hi, just a quick question to understand how the variable system works in UiPath… Are all variables passed by value or are there some cases where references are used?
E.g.
String a = “Test1”
String b = a
a = “Test2”
b = ?
Hi, just a quick question to understand how the variable system works in UiPath… Are all variables passed by value or are there some cases where references are used?
E.g.
String a = “Test1”
String b = a
a = “Test2”
b = ?
hi @DEATHFISH,
Here the value of b will be test1 only as it works by passed by value logic. Attaching a sample workflow for your reference.
Regards,
Shiva KathikReference.xaml (4.7 KB)
Actually, there are some variables treated like Objects that are by default assigned by reference, not by value. For instance, the DataTable.
@Shiva_Karthik is right, the String is treated as a primitive in his example.
Like I’ve said, if you copy a DataTable, its reference is copied by default (shallow copy).
Consider the following assignments:
DataTable second = DataTable first
second.Rows(0)(0) = “modified value”
At this point, first(0)(0) will also be “modified value”.
Also, if you modify a DataRow which is part of a DataTable, the result will be modified in the DataTable also.
It would be nice to have a list of variable types and the way in which UiPath passes the content (value or reference). I think that the String object does not inherit by default UiPath’s generic “Object[]” (i.e. it is by default “unboxed”), while DataTable does.
Maybe someone can come with further details.
Regards,
Daniel