Append command isn't working.
Description
Details
- Legacy ID
- 4282309629
- Severity
- None
- Resolution
- No Bug
- Reproducibility
- Always
- Category
- Scripting
Go to editor
Paste ["test"] append ["test"] into spectate section
See no result
Event Timeline
No bug.
Thats not how append is suppossed to work. You add an array to an already existing array.
Try this instead:
_arr = ["test0"];
_arr append ["test1"];
_arr
-> ["test0", "test1"]
For adding one element it's recommended to use pushBack instead:
_arr = ["test0"];
_arr pushBack "test1";
_arr
-> ["test0", "test1"]
_arr = ["test0"];
_arr append ["test1"];
_arr
is the same like
_arr = ["test0"] append ["test1"]
and is the same syntax like
["test"] append ["test"]
using the watch section will give you the result immediately in the debug console
test it out
No it's not!
append doesn't return anything. If you only put ARRAY append ARRAY into the console, you obviously won't see anything. You have to use a pointer to a previously created array, so you can reference it later.
What you did can be compared to:
_arr = ["test0"];
_arr append ["test1"];
append doesn't return and therefore you don't see anything. The third line is the important one. That one is impossible with your set up, because you never saved the array pointer in a variable.
I also have had problems with 'append', though I tossed it up to incorrect usage and didn't look into it.
used it to replace instances of (array1 + array2).
Such as: (array1 append (array2 append array3))
Does not seem to work for those uses, I am guessing I just don't yet understand 'append'.
pushBack only works for arrays created in script language.
for instance, you cannot do (allDeadMen pushBack [man])
You are having a similar issue as @chris579. append and pushBack are meant to manipulate already existing arrays. They ARE NOT replacements for ARRAY + ARRAY that are magically faster.
The reason they are faster is, as I said, that they don't create arrays but manipulate already existing ones.
Your first example has to be:
array1 append array2;
array1 append array3;
And the second one:
_allDeadAndThatGuy = allDeadMen;
_allDeadAndThatGuy pushBack man;