Hey guys,
I'm trying to use .link() in a script i'm working on. I would assume it would work like this,
PHP Code:
function onCreated() {
this.number = 5;
temp.clone = this.number;
temp.clone = 10;
printf("this.number = %i", this.number); //Outputs 5
printf("temp.clone = %i", temp.clone); //Outputs 10
echo("--------");
temp.link = this.number.link();
printf("temp.link = %i", temp.link); //Outputs 5
temp.link = 20;
printf("this.number = %i", this.number); //Outputs 5 -- Expected 20?
printf("temp.clone = %i", temp.clone); //Ouputs 10
printf("temp.link = %i", temp.link); //Outputs 20
}
I also tried a different example,
PHP Code:
function onCreated() {
this.num1 = 1;
this.num2 = 2;
this.array = {this.num1.link(), this.num2.link()};
printf("Pre-Change: %s", this.array);
for (i=0; i<2; i++)
this.array[i] = 20;
printf("Post-Change: %s", this.array);
echo("this.num1 = " @ this.num1);
echo("this.num2 = " @ this.num2);
}
Pre-Change: 1,2
Post-Change: 20,20
this.num1 = 1
this.num2 = 2
This was tested on Testbed.
I would have thought temp.link = this.number.link(); would make temp.link reference this.number rather than copying the object but the output shows opposite.
Is .link() supposed to be returning a reference or is it providing another use?