Chapter 4. Control Flow

Julia offers many of the control statements that are familiar to the other languages, while also simplifying the syntax for many of them. However, tasks are probably new; they are based on the coroutine concept to make computations more flexible.

We will cover the following topics:

  • Conditional evaluation
  • Repeated evaluation
  • Exception handling
  • Scope revisited
  • Tasks

Conditional evaluation

Conditional evaluation means that pieces of code are evaluated, depending on whether a Boolean expression is either true or false. The familiar if-elseif-else-end syntax is used here, which is as follows:

# code in Chapter 4\conditional.jl
var = 7
if var > 10
    println("var has value $var and is bigger than 10.")
elseif var < 10 println("var has value ...

Get Getting Started with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.