Thanks for your response. Yes, type in the select block. Thanks for letting me know I am on the right track... On Sun, Aug 18, 2019 at 12:00:06PM -0400, pharo-users-request@lists.pharo.org wrote:
Send Pharo-users mailing list submissions to pharo-users@lists.pharo.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.pharo.org/mailman/listinfo/pharo-users_lists.pharo.org or, via email, send a message with subject or body 'help' to pharo-users-request@lists.pharo.org
You can reach the person managing the list at pharo-users-owner@lists.pharo.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Pharo-users digest..."
Today's Topics:
1. Re: As a SmallTalk youngster: A few questions... (Jupiter Jones) 2. Re: As a SmallTalk youngster: A few questions... (Jupiter Jones)
----------------------------------------------------------------------
Message: 1 Date: Sun, 18 Aug 2019 09:09:39 +1000 From: Jupiter Jones <jupiter.jones@mail.com> To: Any question about pharo is welcome <pharo-users@lists.pharo.org> Subject: Re: [Pharo-users] As a SmallTalk youngster: A few questions... Message-ID: <A74A4769-94D9-4B10-8C74-A8F801806E9D@mail.com> Content-Type: text/plain; charset="utf-8"
The difficulty I am having is that when I want to query the UserManager db with something like:
--- RcIdentityBag(users) select: [ :each | each name := 'somename' ] ?
Not sure if it?s just a typo, but it appears you?re trying to use assignment ( := ) rather than comparison ( = ) so shouldn?t this be:
select: [ :each | each name = 'somename' ]
It seems that currently the only I know how to do this is to create a select: method in UserManager simply to pass the desired search string into the UserManager class such that I can use the Collection Classes api to do the actual work, as per:
--- Pardon the not so smalltalky code --- UserManager>>select: aString | resultSet | resultSet := users select: [ :each | each name := aString ]. ^resultSet ---
I believe I read somewhere that in order to avoid this clunkiness that I could refer to the users collection in UserManager via a symbol and access the api of the identitySet directly. Something like:
--- UserManager class>>current
UserGlobals at: #FOO put users. ... ---
But when I do this I am unable to do something like:
--- #FOO add: user ---
This isn?t really necessary - it?s totally up to your application design. The singleton will work fine.
Finally Questions:
1. Am I totally off the mark with the use of smalltalk symbols? 2. Must I create the API in the managing class to perform the specific functions I need from the collection API with respect to querying the collection? 3. Is there a smalltalk way of doing this properly that I missed (reading all the docs I can find in random order based of info I need - probably missing the finer points)?
Any nudge in the correct direction would be greatly appreciated.
It all looks good, apart from the select block.
Cheers