What's the good way to add a new item in array?

ie. if I have the following:


return Array.append<Project>(theProjectsNew, [newProject]);

which appends a new object “newProject” to an array called “theProjectsNew”

and replace it with:


let theProjectsBuffer : Buffer.Buffer = Buffer.Buffer(theProjectsNew.size());

for (x in theProjectsNew.vals()) {

theProjectsBuffer.add(x);

};

theProjectsBuffer.add(newProject);

return theProjectsBuffer.toArray();

the programatic results are the same … and the warning goes away … is this a valid way forward? and leave things otherwise as stable arrays?

2 Likes