Pass by reference

Very basic question:

how to pass global variables by reference (e.g. change their values)?

~zxc = {arg a; a=3}

~afa = 6
~zxc.(~afa)
~afa

I believe that the way to achieve this in SC is by using a Ref object or storing your value in e.g. a Dictionary that you pass to the function.

Thanks, it works actually in this way:

~zxc = {arg a; currentEnvironment[a]=3}

~afa = 6
~zxc.(\afa)
~afa
1 Like