May 2019
Beginner to intermediate
466 pages
10h 44m
English
What should you do when you want to skip one (or more) loop repetitions then, nevertheless, continue with the next loop iteration? For this, you need continue, as in this example:
for n in 1:10
if 3 <= n <= 6
continue # skip current iteration
end
println(n)
end
This prints out, 1 2 7 8 9 10, skipping the numbers three to six, using a chained comparison.
There is no repeat...until or do...while construct in Julia. A do...while loop can be simulated as follows:
while true # code condition || break end
Read now
Unlock full access