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 › Append an array of objects
Page Index Toggle Pages: 1
Append an array of objects (Read 749 times)
Append an array of objects
Dec 5th, 2006, 12:46pm
 
Hi there I am a little confused as to how to append a new object onto an array of objects. Why does this not work? How should I do this?

SourceFiles[] = append(SourceFiles, new Source());


thanks for your help
Re: Append an array of objects
Reply #1 - Dec 5th, 2006, 1:20pm
 
The syntax is:
Code:
MyObjectType[] myArray;
myArray=new MyObjectType[0]; //start off empty
myArray=(MyObjectType[])append(myArray,new MyObjectType(someValues));
Re: Append an array of objects
Reply #2 - Dec 7th, 2006, 12:53pm
 
Hi Thanks John.
But I can't get this to work.
I get the "Perhaps you wanted the overloaded version ..." error.

Can anybody make this work and post a quick code segment?
Re: Append an array of objects
Reply #3 - Dec 7th, 2006, 1:51pm
 
Post the code and the full error, and I'm sure we'll be able to help.
Re: Append an array of objects
Reply #4 - Dec 8th, 2006, 3:45pm
 
I got it working.

Thanks again!
Page Index Toggle Pages: 1