[Cuis-dev] Additional collection methods reject:thenDo: and reject:thenCollect:

Ezequiel Birman ebirman77 at gmail.com
Fri Mar 7 08:24:24 PST 2025


Hello

I wanted a *reject:thenDo:*. so instead of:

| taskbar userInterface |
>
> "If we were to ommit this, the taskbar wouldn't exist yet, and therefore
> taskbar would be initialized to nil"
> *self runningWorld doOneCycleNow.*
>
>
> *userInterface := UISupervisor ui.taskbar := userInterface taskbar.*
>
> "Remove all morphs except for the taskbar. We also leave code windows
> intact in case we are recovering from a crash."
> *userInterface submorphs*
> *    select: [ :morph | (morph isKindOf: CodeWindow) not and: [ morph ~=
> taskbar ]]*
> *    thenDo: #delete.*


I can rewrite:

> "Remove all morphs except for the taskbar. We also leave code windows
> intact in case we are recovering from a crash."
> *userInterface submorphs*
> *    reject: [ :morph | (morph isKindOf: CodeWindow) or: [ morph = taskbar
> ]]*
> *    thenDo: #delete.*


While I was at it, I refactored *select:ThenCollect:* to avoid iterating
twice, then added a *reject:thenCollect:* just for the sake of symmetry.

I attach the changeset in case you find it useful; but I wanted to know
what is your opinion on adding tests that exercise higher-level messages
like these. If they are needed or wanted, I can also add them to
BaseImageTests.

-- 
Eze
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250307/f8d8ed49/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 7067-CuisCore-EzequielBirman-2025Mar07-14h57m-Ez3.001.cs.st
Type: application/octet-stream
Size: 663 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250307/f8d8ed49/attachment.obj>


More information about the Cuis-dev mailing list