On 06/28/2011 07:49 PM, Holger Hans Peter Freyther wrote:
copy do: [:each |
        each isTooOld ifTrue: [^true].
        each doStuff
        orig remove: each
].


Now I started to dispatch the block to another process (to avoid some locking
issues right now..) but obviously I get a BadReturn when invoking it in
another Context. Is there something like a 'break' for Iterable>>do:? is there
any other selector to help me?

There's of course exception handling, but that's pretty heavyweight. I've seen people use this:

Iterable>>withBreakDo: aBlock
    break := [ :value | ^self].
    self do: [ :each | aBlock value: each value: break].

so that you can do

copy do: [ :each |
    each isTooOld ifTrue: [break value: true].
    each doStuff
    orig remove: each ]

One thing I can think of is something like this...

[copy isEmpty not and: [copy first isJounEnough]] whileTrue: [].

anything else?

This one definitely has better performance.

Paolo

_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to