I see makeref() used throughout various scripts but I don't see a valid use case for it and haven't been able to come up with a reason for its existence. I suspect that it may be an artifact of an earlier version of the scripting language before the '&' operator became available.
Here is an example using makeref() to create a reference to a variable 'num' as 'rNum'. It can be demonstrated than 'rNum' references 'num':
This function isn't necessary since the '&' operator can already be used to assign a reference:
There are no problems working with arrays either:
Is there an actual use case for makeref() or is it considered a deprecated feature?
Here is an example using makeref() to create a reference to a variable 'num' as 'rNum'. It can be demonstrated than 'rNum' references 'num':
Code:
string num = 123;
ref rNum; makeref(rNum, num)
rNum = 456;
trace(num); // Outputs 456
This function isn't necessary since the '&' operator can already be used to assign a reference:
Code:
string num = 123;
ref rNum = #
rNum = 456;
trace(num); // Outputs 456
There are no problems working with arrays either:
Code:
int list[2];
list[0] = 123;
ref rNum = &list[0];
rNum = 456;
trace(list[0]); // Outputs 456
Is there an actual use case for makeref() or is it considered a deprecated feature?