Open In App
Related Articles

Julia continue Keyword | Continue iterating to next value of a loop in Julia

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
Keywords in Julia are predefined words that have a definite meaning to the compiler. These keywords can’t be used to name variables. 'continue' keyword in Julia skips the statement immediately after the continue statement. Whenever the continue keyword is executed, the compiler immediately stops iterating over further values and sends the execution pointer back to the next iterating value in the loop. Syntax:
loop condition
    statement
    statement
    continue
    statement
end
Example 1:
# Julia program to illustrate
# the use of 'continue' keyword
   
# Defining for-loop
for i in 1:10
    if iseven(i)
        # Using 'continue' keyword
        continue
    else
        println(i)
    end
end

                    
Output:
1
3
5
7
9

Example 2:
# Julia program to illustrate
# the use of 'continue' keyword
   
i = 0
   
# Defining while-loop
while i < 10
    global i = i + 1
    if iseven(i)
        # Using 'continue' keyword
        continue
    else
        println(i)
    end
end

                    
Output:
1
3
5
7
9


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!


Last Updated : 26 Mar, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads