[Newbies] Re: next or break in a loop

Joseph Alotta 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:
> 
> Joe, 
> 
> At each test for the type of data you can also test to see if you found type, something like 
> this: 
> 
>         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.

Sincerely,

Joe.






--
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...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20160510/6fc8e8b1/attachment.htm


More information about the Beginners mailing list