Adding null-coalescing operator

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

# 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.

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:

const ⩌ = something

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

4 Likes

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