logo       

Re: Re: Some general questions: msg#00124

lang.smalltalk.squeak.beginners

Subject: Re: Re: Some general questions

Hello Darren,



DW> 10 timesRepeat: [
DW> x := 1 asString.
DW> ''the value of x can be any string object"
DW> user"how do I add x to be part off the name so I end up with
DW> variable named user1 user2 ... " := User new.
DW> x := x + x.]

if I don't misunderstand you, you want to put your users in a subclass
of Collection, first guess is OrderedCollection. There is no need to
have a single variable with a unique name for each user.

So up to now I don't understand why the system should name the object.

Is it a possibility to say:

users := OrderedCollection new.

Then a user enters his details in an instance of class User and you
put it into the collection users by:

newUser := User new.
user name: .... "to add the name to the new user"

users add: newUser. "to stuff this user into the collection of users"

Collection and subclasses offer methods like:

users select: [:eachUser | eachUser name = 'willi']

to give you a collection of all users named 'willi'.

If this points in the right direction read up on collections and their
enumeration methods.

Else hope for someone to understand you better or clarify your
intentions for me :-))



Cheers


Herbert mailto:herbertkoenig@xxxxxxx


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise