且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

数组的旧值替换为数组的新值

更新时间:2023-12-05 13:25:22

我假设它存在于函数中.

I'm assuming this is present inside a function.

该代码的问题可能是将waypts设置为局部变量.

The problem with the code might be that waypts is made a local variable.

如果在其他任何地方引用它,则无法获取该值.

If it is referred anywhere else, the value cannot be obtained.

每次调用函数时都会重新初始化变量,因此存储在数组中的所有先前值都将丢失.

The variable is reinitialized each time the function is called, so any previous values stored in the array will be lost.

waypts设置为全局,然后尝试在函数外部定义变量.

Make waypts global and try by defining the variable outside the function.