|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
break and continueThey exist in Nim and they work just like in Python/C. However, when you have nested loops, you can break out of an outer loop (Java has this too). Take this example: for i in 1..3: for j in 1..2: echo &"{i} - {j}" Output: 1 - 1 1 - 2 2 - 1 2 - 2 3 - 1 3 - 2 Say we want to stop the loops after "2 - 2". Here is how to do it: block outer: for i in 1..3: for j in 1..2: echo &"{i} - {j}" if i == 2 and j == 2: break outer echo "" A Output: 1 - 1 1 - 2 2 - 1 2 - 2 The block keywordThe
Comments are given in the C code (left side). The same thing happens in Nim. Now the |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |
||||