Julia Language Conditionals

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • if cond; body; end
  • if cond; body; else; body; end
  • if cond; body; elseif cond; body; else; end
  • if cond; body; elseif cond; body; end
  • cond ? iftrue : iffalse
  • cond && iftrue
  • cond || iffalse
  • ifelse(cond, iftrue, iffalse)

Remarks

All conditional operators and functions involve using boolean conditions (true or false). In Julia, the type of booleans is Bool. Unlike some other languages, other kinds of numbers (like 1 or 0), strings, arrays, and so forth cannot be used directly in conditionals.

Typically, one uses either predicate functions (functions that return a Bool) or comparison operators in the condition of a conditional operator or function.



Got any Julia Language Question?