O'Reilly logo

Learning Julia by Rahul Lakhanpal, Anshul Joshi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Conditional evaluation in detail

While writing any code, we are often confronted with situations where we need to make some decisions based on a set of rules or predefined business logic. In such cases, we would generally expect the code to be intelligent enough that it can take the right path accordingly. Here is when conditional evaluation comes into the picture.

Let's have a look at the example of FizzBuzzHere, we will be implementing the famous FizzBuzz program which states that, for any given range of numbers (let's say 1 to 30), print Fuzz instead of the number for multiples of 3 and Buzz for multiples of 5. For numbers which are both divisible by 3 and 5, the program should print FizzBuzz.

julia> for i in 1:30 if i % 3 == 0 && i ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required