# Adding null-coalescing operator

**URL:** <https://discourse.julialang.org/t/adding-null-coalescing-operator/39318>\
**Category:** Internals & Design\
**Created:** [May 12, 2020, 2:16am UTC](https://discourse.julialang.org/t/adding-null-coalescing-operator/39318 "2020-05-12T02:16:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zachmatson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zachmatson/32/9397_2.png) [@zachmatson](https://discourse.julialang.org/u/zachmatson)\
**Post date:** [May 12, 2020, 2:16am UTC](https://discourse.julialang.org/t/adding-null-coalescing-operator/39318/1 "2020-05-12T02:16:48Z")

</div>

C# has the “null-coalescing operator” `??` which equates to:

```julia
# Existing syntax
a = !isnothing(b) ? b : c
# Equivalent if ?? introduced
a = b ?? c

```

I don’t think this is an especially important or foundational operator, but it is useful in some contexts, especially where it can be chained. Could be worth consideration for adding to the language.

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [May 12, 2020, 2:50am UTC](https://discourse.julialang.org/t/adding-null-coalescing-operator/39318/2 "2020-05-12T02:50:48Z")

</div>

The function `something` is the julia equivalent. So you could easily override one of the many available unicode operators as an alias of `something` if having it as an operator is important to you:

```julia
const ⩌ = something

```

(symbol chosen completely at random without any regard to whatever notational meaning it might ordinarily have)

---

<div class="post-metadata">

**Author:** ![zachmatson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zachmatson/32/9397_2.png) [@zachmatson](https://discourse.julialang.org/u/zachmatson)\
**Post date:** [May 12, 2020, 3:01am UTC](https://discourse.julialang.org/t/adding-null-coalescing-operator/39318/3 "2020-05-12T03:01:26Z")

</div>

Wow, didn’t realize we had this, not much of a suggestion then I guess 😆
