Understanding Julia

This is called short-circuit evaluation for control flow (explained here in the manual).

In short when you use && (reads “and”) the thing in the right side of the operator is evaluated only if the thing in the left evaluates to true (if the thing in the right is not true then it does not make sense to compute it).

So people use it to control the flow of a program. That part is equivalent to:

if lb > best_cost
   continue
end
for v in set
    #do something 
end

end

If lb > best_cost the thing loop continues to the next iteration without computing the inner for loop.

3 Likes