Loops/Continue: Difference between revisions
Content added Content deleted
m ({{Out}} / moved Category to top) |
|||
Line 1,251: | Line 1,251: | ||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
Scala doesn't have a <code>continue</code> keyword. |
|||
[[Category:Scala Implementations]] |
|||
However, you may not even miss it, <code>if</code> could be used here. |
|||
===The intuitive way=== |
===The intuitive way=== |
||
<lang scala>for (i <- 1 to 10) { |
<lang scala>for (i <- 1 to 10) { |
||
Line 1,258: | Line 1,259: | ||
if (i % 5 == 0) println() else print(", ") |
if (i % 5 == 0) println() else print(", ") |
||
}</lang> |
}</lang> |
||
===Functional solution=== |
===Functional solution=== |
||
Thinking In Scala<sup>©</sup> says: we avoid for loops and handle it the [[functional_programming|Functional]] way: |
Thinking In Scala<sup>©</sup> says: we avoid for loops and handle it the [[functional_programming|Functional]] way: |