November 2017
Beginner
316 pages
6h 40m
English
We have, so far, read and experimented a great deal about the for and while constructs. However, as also provided by many different languages, we have continue as well as break statements.
The break block is used in places when we want the control to be shifted to an outer block of code. This means that we do not want to go further into evaluation, and want to immediately break and come out from that loop cycle. To understand this, let's look at the following example:
julia> word = "julia"
"julia"
julia> for letter in word
println(letter)
if letter == 'l'
break
end
end
j
u
l
Here, we have a word with the "julia" value. We want a solution to come out of the for loop as soon as we encounter the l letter in the name. This ...
Read now
Unlock full access