Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Dan Peach on May 06, 2016, 10:09:27 PM

Title: How to empty an array
Post by: Dan Peach on May 06, 2016, 10:09:27 PM
Hello :)

I have an array that I use to pass some information to a method. Once the method has done, I want to empty the array so that I can use it again. How to empty it?

Thanks. :)

Dan.
Title: Re: How to empty an array
Post by: anarchist on May 06, 2016, 11:27:11 PM
Hi Dan. You can simply reassign the variable it a new array:

Code: WME Script
  1. arrayVariable = new Array();
  2.  

or you can set Lenght to 0 (I haven't tested this, it's according to the documentation):

Code: WME Script
  1. arrayVariable.Length = 0;
  2.  
Title: Re: How to empty an array
Post by: Dan Peach on May 07, 2016, 12:39:44 AM
Thank you. The second one worked.  ;D
Title: Re: How to empty an array
Post by: piere on May 19, 2016, 02:32:26 AM
Would arrayVariable.Length = null; work also ?