How can I convert an object to an array, and should I?
Posted: Fri Jun 23, 2006 9:29 am
I am new to object oriented coding. I have written my code so that each user is an object. When the user object is created, it sets all of the user objects attributes, some of which take multiple steps and database queries to determine.
I need (I want) to make an array of user objects, so that I can list them, compare them, etc. I am assuming that having many objects in an array will take up more cpu resources that to have many sub-arrays. Since I'll not be modifying the data, or calling any methods, I'm assuming I should convert the objects to arrays. But I can't find instructions (a function) to do this.
My questions are...
1. Does an object take up more cpu resources than an array with the same attributes/elements?
2. If so, how do you convert an object to an array?
If I am over-complicating this, please tell me. Thanks in advance.
I need (I want) to make an array of user objects, so that I can list them, compare them, etc. I am assuming that having many objects in an array will take up more cpu resources that to have many sub-arrays. Since I'll not be modifying the data, or calling any methods, I'm assuming I should convert the objects to arrays. But I can't find instructions (a function) to do this.
My questions are...
1. Does an object take up more cpu resources than an array with the same attributes/elements?
2. If so, how do you convert an object to an array?
If I am over-complicating this, please tell me. Thanks in advance.