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 ...

Get Learning 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.