Loops/Continue: Difference between revisions

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