Page MenuHomeFeedback Tracker

append not working
Closed, ResolvedPublic

Description

Append command isn't working.

Details

Legacy ID
4282309629
Severity
None
Resolution
No Bug
Reproducibility
Always
Category
Scripting
Steps To Reproduce

Go to editor

Paste ["test"] append ["test"] into spectate section

See no result

Event Timeline

chris579 edited Steps To Reproduce. (Show Details)Aug 27 2015, 5:49 PM
chris579 set Category to Scripting.
chris579 set Reproducibility to Always.
chris579 set Severity to None.
chris579 set Resolution to No Bug.
chris579 set Legacy ID to 4282309629.May 8 2016, 12:35 PM
commy2 added a subscriber: commy2.May 8 2016, 12:35 PM

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])

@MDCCLXXVI

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;

Adam added a comment.Aug 28 2015, 8:36 AM

commy2 is right. It is supposed to work that way. Thank you for your feedback.