# What does this mean in Julia

**URL:** <https://discourse.julialang.org/t/what-does-this-mean-in-julia/83799>\
**Category:** General Usage\
**Created:** [July 5, 2022, 9:04pm UTC](https://discourse.julialang.org/t/what-does-this-mean-in-julia/83799 "2022-07-05T21:04:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JosieG](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josieg/32/36221_2.png) [@JosieG](https://discourse.julialang.org/u/JosieG)\
**Post date:** [July 5, 2022, 9:04pm UTC](https://discourse.julialang.org/t/what-does-this-mean-in-julia/83799/1 "2022-07-05T21:04:36Z")

</div>

Hi I’m very new to Julia and I’m given this code in Julia.

> r[k] = length(m) \> 0 ? median(m) : missing

What does this mean in Julia?  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [July 5, 2022, 9:08pm UTC](https://discourse.julialang.org/t/what-does-this-mean-in-julia/83799/2 "2022-07-05T21:08:40Z")

</div>

It is the same as:

```julia
if isempty(m)
    r[k] = missing
else
    r[k] = median(m)
end

```

In other words, you store in `r[k]` the median of `m` collection. However, it might happen that `m` has no elements, in which case median is not well defined so instead `missing` (signaling missing value) is stored.

---

<div class="post-metadata">

**Author:** ![ronubi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronubi/32/4085_2.png) [@ronubi](https://discourse.julialang.org/u/ronubi)\
**Post date:** [July 5, 2022, 9:24pm UTC](https://discourse.julialang.org/t/what-does-this-mean-in-julia/83799/3 "2022-07-05T21:24:22Z")

</div>

Quoting from the Julia manual, at [Conditional Evaluation](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 `:`).

* * *

This works almost identically to the ternary operator in the **C** programming language.

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [July 5, 2022, 9:32pm UTC](https://discourse.julialang.org/t/what-does-this-mean-in-julia/83799/4 "2022-07-05T21:32:55Z")

</div>

And a wiki page describing the ternary operator in many different languages [?: - Wikipedia](https://en.wikipedia.org/wiki/%3F:)
