# Seven Lines of Julia (examples sought)

**URL:** https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416
**Category:** General Usage
**Created:** [November 19, 2020, 7:37am UTC](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416 "2020-11-19T07:37:29Z")
**Posts on this page:** 1
**Showing post:** 189

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [December 14, 2022, 1:29pm UTC](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416/189 "2022-12-14T13:29:10Z")

</div>

From: [Control Flow · The Julia Language](https://docs.julialang.org/en/v1/manual/control-flow/#man-conditional-evaluation)

The so-called “ternary operator”, `?:`, is closely related to the `if`-`elseif`-`else` syntax, but is used where a conditional choice between single expression values is required, as opposed to conditional execution of longer blocks of code. It gets its name from being the only operator in most languages taking three operands:

```julia
a ? b : c

```

The expression `a`, before the `?`, is a condition expression, and the ternary operation evaluates the expression `b`, before the `:`, if the condition `a` is `true` or the expression `c`, after the `:`, if it is `false`. Note that the spaces around `?` and `:` are mandatory: an expression like `a?b:c` is not a valid ternary expression (but a newline is acceptable after both the `?` and the `:`).

---

_[View the full topic](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416)._
