|
Re: Re: Some general questions: msg#00123lang.smalltalk.squeak.beginners
On Wed, 2007-05-23 at 15:37 +0100, Darren White wrote: > Hello, Thanks fro the replies. > > I think my first question was a little fuzzy. I think what I need to > do as change the question. > > If for example I have a seaside web app and users need to create an > account. Now, for each user I create an object, say an instance of > class Users, which has instance variables such as name and address. So > the new user puts in their detail such as name, address, telephone > number and then click register. How should (not what) the system name > this object. What I'm confused about is I don't know how may users the > system will have have do I name all the user object; I can't call them > all aUser . If the first user gets an object named user1 how do I > create another instance of User named user2 or What about If I want to > use one of the input field as part of the name of the object? > > > The example below may make it clear what I mean > > 10 timesRepeat: [ > x := 1 asString. > ''the value of x can be any string object" > user"how do I add x to be part off the name so I end up with variable > named user1 user2 ... " := User new. > x := x + x.] > Why not using a collection for this. If I understand you right, you just need a bunch of user objects. If you think you need some kind of index just use an OrderedCollection. users := OrderedCollection new. 10 timeRepeat: [ users add: User new. ] Then you have even the chance to access them by index firstUser := users at: 1 hope this helps, Norbert
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Re: Some general questions, Bert Freudenberg |
|---|---|
| Next by Date: | Re: Re: Some general questions, Herbert König |
| Previous by Thread: | Re: Some general questions, nicolas cellier |
| Next by Thread: | Re: Re: Some general questions, Herbert König |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |