SuperC documentation

Nullish coalescing operator

This is already implemented in GNU C

The nullish coalescing operator is a ternary operator that returns its right operand if the left operand is NULL, and its left operand otherwise.

i.e. a ?: b is equivalent to a ? a : b

Note: that operator overload for __ne__ does not work for nullish coalescing operator, because (x != 0) is not tested, it’s just the variable “truthiness”. If you want to test the operator overload, use explicit ternary operator x != 0 ? x : y.

Examples


Previous

Switch ranges

Next

Type methods
Playground