Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: How to empty an array  (Read 5532 times)

0 Members and 1 Guest are viewing this topic.

Dan Peach

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 100
    • View Profile
    • Viperante - Game Development
How to empty an array
« 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.

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: How to empty an array
« Reply #1 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.  
Logged

Dan Peach

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 100
    • View Profile
    • Viperante - Game Development
Re: How to empty an array
« Reply #2 on: May 07, 2016, 12:39:44 AM »

Thank you. The second one worked.  ;D

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: How to empty an array
« Reply #3 on: May 19, 2016, 02:32:26 AM »

Would arrayVariable.Length = null; work also ?
Logged
 

Page created in 0.024 seconds with 20 queries.