nuget server logo nuget api documents
↑

API Docs / REnv / NullishCoalescing

NullishCoalescing

Full name SMRUCC.Rsharp.Interpreter.ExecuteEngine.ExpressionSymbols.Operators.NullishCoalescing Assembly REnv Members 7

The nullish coalescing (??) operator is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand.

 x ?? default

00 Remarks

The nullish coalescing operator can be seen as a special case of the logical OR (||) operator. The latter returns the right-hand side operand if the left operand is any falsy value, not only null or undefined. In other words, if you use || to provide some default value to another variable foo, you may encounter unexpected behaviors if you consider some falsy values as usable (e.g., '' or 0).

The nullish coalescing Operator has the fifth-lowest Operator precedence, directly lower than || And directly higher than the conditional (ternary) Operator.

It Is Not possible to combine both the And (&&) And Or operators (||) directly with ??. A syntax error will be thrown in such cases.

01 Syntax

SMRUCC.Rsharp.Interpreter.ExecuteEngine.ExpressionSymbols.Operators.NullishCoalescing

02 Methods

NameOverloadsSummary
Evaluate 1
ToString 1

03 Properties

NameOverloadsSummary
type 1
expressionName 1
value 1
default 1
operator 1

04 Members

property type #
type
property expressionName #
expressionName
property value #
value
property default #
default
property operator #
operator
method Evaluate #
Evaluate(Environment)
method ToString #
ToString()