From the course: Learning Julia

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Conditional statements

Conditional statements - Julia Tutorial

From the course: Learning Julia

Start my 1-month free trial

Conditional statements

- [Instructor] One of the key parts of programming is controlling the execution flow of your program. In this chapter we're going to learn about the different kinds of flow control provided by Julia. Now most of this is pretty standard, so if you are already familiar with other languages, then all of this will look very familiar to you. And we're going to start off with conditional statements. These are statements that evaluate a logical expression and then take action based up on the result. So I'm going to open conditionals_start. So one of the most basic of these is the if statement. It takes a condition and executes some code if the condition evaluates to true. So to take a very simple example, let's imagine that we had a variable with a value like five and you can see I've got a variable named x there and we wanted to print a statement based upon that value. So I can use an if statement to do that. What I'll write is if x is less than 10, whoops, then print line x is small. And…

Contents