[Newbies] Re: next or break in a loop
joseph.alotta at gmail.com
Tue May 10 19:44:55 UTC 2016
> On May 10, 2016, at 12:03 PM, Louis LaBrunda [via Smalltalk] <ml-node+s1294792n4894224h93 at n4.nabble.com> wrote:
> At each test for the type of data you can also test to see if you found type, something like
> stream := ReadStream on: myCollection.
> [stream atEnd] whileFalse: [:item | | notFound |
> item := stream next.
> notFound := true.
> (notFound and: [your column test1]) ifTrue: [notFound := false. stream upToEnd].
> (notFound and: [your column test2]) ifTrue: [notFound := false. stream upToEnd].
> (notFound and: [your column test3]) ifTrue: [notFound := false. stream upToEnd].
> Not pretty but it should work.
I added a flag and set it as one of the conditions.
Also, to make reading simpler, I stacked all the booleans.
bool := bool and: (condition).
bool := bool and: (another condition).
It is not pretty, but it avoids endless seas of parentheses.
View this message in context: http://forum.world.st/next-or-break-in-a-loop-tp4894095p4894238.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners