# What is ? mark in Julia?

**URL:** <https://discourse.julialang.org/t/what-is-mark-in-julia/92776>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 10, 2023, 10:19pm UTC](https://discourse.julialang.org/t/what-is-mark-in-julia/92776 "2023-01-10T22:19:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kianoush\_Ramezani\_sh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kianoush_ramezani_sh/32/45765_2.png) [@Kianoush\_Ramezani\_sh](https://discourse.julialang.org/u/Kianoush_Ramezani_sh)\
**Post date:** [January 10, 2023, 10:19pm UTC](https://discourse.julialang.org/t/what-is-mark-in-julia/92776/1 "2023-01-10T22:19:58Z")

</div>

e.g. what does it do here:  
pow2(x, n) = n \<= 0 ? 1 : x\*pow2(x, n-1)  
or here  
minmax(xx, y) = (y \< xx) ? (y, xx) : (xx, y)

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [January 10, 2023, 10:24pm UTC](https://discourse.julialang.org/t/what-is-mark-in-julia/92776/2 "2023-01-10T22:24:19Z")

</div>

If you use the help mode on the REPL by typing `?` you can see the following documentation.

```julia
help?> ?
search: ? ?:

  a ? b : c

  Short form for conditionals; read "if a, evaluate b otherwise evaluate c". Also known as the ternary operator (https://en.wikipedia.org/wiki/%3F:).

  This syntax is equivalent to if a; b else c end, but is often used to emphasize the value b-or-c which is being used as part of a larger expression, rather
  than the side effects that evaluating b or c may have.

  See the manual section on control flow for more details.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> x = 1; y = 2;
  
  julia> x > y ? println("x is larger") : println("y is larger")
  y is larger

```

So basically

```julia
pow2(x, n) = n <= 0 ? 1 : x*pow2(x, n-1)

```

is the same as:

```julia
function pow2(x,n)
    if n<=0
        return 1
    else
        return x*pow2(x,n-1)
    end
end

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [January 10, 2023, 10:24pm UTC](https://discourse.julialang.org/t/what-is-mark-in-julia/92776/3 "2023-01-10T22:24:52Z")

</div>

> [@Kianoush\_Ramezani\_sh](#):
>
> minmax(xx, y) = (y \< xx) ? (y, xx) : (xx, y)

This is eqivalent to

```julia
function minmax(xx, y)
    if y < xx
        return (y, xx)
    else
        return (xx, y)
    end 
end

```

---

<div class="post-metadata">

**Author:** ![mrufsvold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mrufsvold/32/31600_2.png) [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Post date:** [January 10, 2023, 11:34pm UTC](https://discourse.julialang.org/t/what-is-mark-in-julia/92776/4 "2023-01-10T23:34:43Z")

</div>

I love the syntax because it matches how I think about conditional assignment.

In my head “to choose x, ask yourself ‘is y greater than 0?’ if so x should be y, otherwise it should be 0.”

In code:

```julia
x = y > 0 ? y : 0

```

---

<div class="post-metadata">

**Author:** ![torrance](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torrance/32/38990_2.png) [@torrance](https://discourse.julialang.org/u/torrance)\
**Post date:** [January 11, 2023, 6:42am UTC](https://discourse.julialang.org/t/what-is-mark-in-julia/92776/5 "2023-01-11T06:42:48Z")

</div>

Since it wasn’t mentioned earlier, this is known as the ternary conditional operator and is common across most languages: [Ternary conditional operator - Wikipedia](https://en.wikipedia.org/wiki/Ternary_conditional_operator)
