# Null coalescing operator?

**URL:** <https://resource.dopus.com/t/null-coalescing-operator/56340>\
**Category:** Help & Support\
**Created:** [July 2, 2025, 6:04pm UTC](https://resource.dopus.com/t/null-coalescing-operator/56340 "2025-07-02T18:04:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![BuckyB](https://resource.dopus.com/letter_avatar_proxy/v4/letter/b/46a35a/32.png) [@BuckyB](https://resource.dopus.com/u/BuckyB)\
**Post date:** [July 2, 2025, 6:04pm UTC](https://resource.dopus.com/t/null-coalescing-operator/56340/1 "2025-07-02T18:04:32Z")

</div>

Even though the ternary operator (and/or some if() functions) work great in the evaluator, I think having a null coalescing operator would help for readability.  
I must admit that I think it would only help if it would also count empty strings as 'null' though.

---

<div class="post-metadata">

**Author:** ![BuckyB](https://resource.dopus.com/letter_avatar_proxy/v4/letter/b/46a35a/32.png) [@BuckyB](https://resource.dopus.com/u/BuckyB)\
**Post date:** [July 17, 2025, 5:00pm UTC](https://resource.dopus.com/t/null-coalescing-operator/56340/2 "2025-07-17T17:00:52Z")

</div>

Any thoughts on this?

---

<div class="post-metadata">

**Author:** ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)\
**Post date:** [July 17, 2025, 7:46pm UTC](https://resource.dopus.com/t/null-coalescing-operator/56340/3 "2025-07-17T19:46:20Z")

</div>

The evaluator doesn't have the concept of null so I'm not sure how useful this would be. What's an example of how you'd use it?

---

<div class="post-metadata">

**Author:** ![BuckyB](https://resource.dopus.com/letter_avatar_proxy/v4/letter/b/46a35a/32.png) [@BuckyB](https://resource.dopus.com/u/BuckyB)\
**Post date:** [July 17, 2025, 8:00pm UTC](https://resource.dopus.com/t/null-coalescing-operator/56340/4 "2025-07-17T20:00:09Z")

</div>

I understand that null is difficult, which is why I would like it to recognize empty strings (or maybe also 0?):

```auto
x = regex(string, test1, "\1", "e");
y = regex(string, test2, "\1", "e");
return x ?? y // Return either x or y, depending on x being empty

```

---

<div class="post-metadata">

**Author:** ![PassThePeas](https://resource.dopus.com/user_avatar/resource.dopus.com/passthepeas/32/50972_2.png) [@PassThePeas](https://resource.dopus.com/u/PassThePeas)\
**Post date:** [July 17, 2025, 8:22pm UTC](https://resource.dopus.com/t/null-coalescing-operator/56340/5 "2025-07-17T20:22:03Z")

</div>

I think it just does not exist in the jscript version Windows is providing and Opus is relying upon.  
It appeared in more recent version of javascript.

---

<div class="post-metadata">

**Author:** ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)\
**Post date:** [July 18, 2025, 1:00am UTC](https://resource.dopus.com/t/null-coalescing-operator/56340/6 "2025-07-18T01:00:53Z")

</div>

> [@BuckyB](#):
>
> I understand that null is difficult, which is why I would like it to recognize empty strings

Thanks, that makes sense. We'll add this in the next beta. It'll use a "logical not" test, so `x ?? y` will be functionally equivalent to `if (!x) { x = y; }`. That will mean empty strings, the value `0` and the value `false`.

---

<div class="post-metadata">

**Author:** ![David](https://resource.dopus.com/user_avatar/resource.dopus.com/david/32/51561_2.png) [@David](https://resource.dopus.com/u/David)\
**Post date:** [July 18, 2025, 1:32am UTC](https://resource.dopus.com/t/null-coalescing-operator/56340/7 "2025-07-18T01:32:47Z")

</div>

I am looking forward to this.  
I have no particular use for it at this time, but I have a few Regular Expressions that rely on Null Capture Groups.

---

<div class="post-metadata">

**Author:** ![BuckyB](https://resource.dopus.com/letter_avatar_proxy/v4/letter/b/46a35a/32.png) [@BuckyB](https://resource.dopus.com/u/BuckyB)\
**Post date:** [July 18, 2025, 3:44pm UTC](https://resource.dopus.com/t/null-coalescing-operator/56340/8 "2025-07-18T15:44:35Z")

</div>

> [@Jon](#):
>
> We'll add this in the next beta

Thanks, I appreciate it!

---

<div class="post-metadata">

**Author:** ![BuckyB](https://resource.dopus.com/letter_avatar_proxy/v4/letter/b/46a35a/32.png) [@BuckyB](https://resource.dopus.com/u/BuckyB)\
**Post date:** [July 25, 2025, 8:20am UTC](https://resource.dopus.com/t/null-coalescing-operator/56340/9 "2025-07-25T08:20:25Z")

</div>

Works in 13.17.1
