We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › emptying an array
Page Index Toggle Pages: 1
emptying an array (Read 408 times)
emptying an array
Mar 17th, 2006, 2:58am
 
Hi

I've built a small drawing program that stores the points in a 2D array.

I want to be able to empty the array and start drawing again with a clean screen.

Is there a syntax that will empty the array entirely, setting the length to 0 again?

something like

myArray.length = 0;

I can set each entry in the array to 0 with a "for loop" but that doesn't alter the length of the array.

Cheers
Rhian

Re: emptying an array
Reply #1 - Mar 17th, 2006, 9:13am
 
If it is an array of objects

myArray = new ArrayType[0];

If it is an array of floats

myArray = new float[0];

Replace 0 with whatever number your array size is supposed to be.
Page Index Toggle Pages: 1