[Newbies] Does Smalltalk have "break" method to jump out of a loop ?

Benoit St-Jean bstjean at yahoo.com
Fri Nov 17 06:08:19 UTC 2017


0 to: 99 by: 1 do: [ :each | each = 50 ifTrue: [ ^self ] ]

----------------- 
Benoît St-Jean 
Yahoo! Messenger: bstjean 
Twitter: @BenLeChialeux 
Pinterest: benoitstjean 
Instagram: Chef_Benito
IRC: lamneth 
Blogue: endormitoire.wordpress.com 
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein) 

    On Friday, November 17, 2017, 1:00:34 AM EST, RedTigerFish <chihuyu at gmail.com> wrote:  
 
 *1 to: 130 do: [:i| ] *  or  *100 timesRepeat: [ ] *

Maybe because I learned some C before. I thought the above two are loops.


The following is "break" example in C. How to implement that in Smalltalk? 

#include <stdio.h>
void main() 
{  
    for (int i = 0; i < 100; i++) 
        if (i == 50) 
              break; 
}



-----
Dig, dig where you are,
Down below's well.
Let those that walk in darkness shout, 
Down below's hell.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
Beginners at lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20171117/6bb69325/attachment.html>


More information about the Beginners mailing list