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 › change all arrays at once
Page Index Toggle Pages: 1
change all arrays at once? (Read 671 times)
change all arrays at once?
Jan 9th, 2010, 5:24am
 
hello,
does anyone know if it is possible to change all pieces of an allready initiated array with one line of code?

i want to do something like this:

int[] lColor = new int[6];
...
...
...
lColor[] = {0,255,0,20,0,20};

is there a way to do this or must i change every single array piece itself?

and another array question:
can you pass an array to a function?

something like:
int[] lColor = new int[6];
...
update(lColor);
...
void update(int[6] mColor) {
...
}

thank you!
Re: change all arrays at once?
Reply #1 - Jan 9th, 2010, 7:26am
 
There was a recent thread about this, so I can answer... Smiley
You can do: lColor = new int[] { 0, 255, 0, 20, 0, 20 };
And the parameter syntax is:
void update(int[] mColor)
ie. you don't specify the size.
Re: change all arrays at once?
Reply #2 - Jan 9th, 2010, 8:07am
 
thanks a lot, that did the trick Smiley
Page Index Toggle Pages: 1