exprv4:reference:methods:common_value_methods



Common Value Methods

Common value methods can be called on any Expr value: `none()`, numbers, strings, and objects.

They are mostly used for validation before a script performs numeric work, string parsing, or optional-value handling.


is_none()

Checks whether the value is `none()`.

Item Description
Syntax `value.is_none()`
Arguments none
Returns boolean-style number

Example:

value = none();
 
if(value.is_none())
{
    print('missing value');
};

is_nan()

Checks whether the value is numeric NaN.

Item Description
Syntax `value.is_nan()`
Arguments none
Returns boolean-style number

Only a numeric NaN value returns true.

Example:

value = nan();
 
value.is_nan();       // true

is_num()

Checks whether the value is a number.

Item Description
Syntax `value.is_num()`
Arguments none
Returns boolean-style number

NaN is still a number, so `nan().is_num()` returns true.

Example:

(123).is_num();       // true
nan().is_num();       // true
'123'.is_num();       // false

is_num_notnan()

Checks whether the value is a usable number and not NaN.

Item Description
Syntax `value.is_num_notnan()`
Arguments none
Returns boolean-style number

Use this before calculations that require a valid numeric value.

Example:

if(feed.is_num_notnan() && feed > 0)
{
    print('valid feed');
};

is_num_int()

Checks whether the value is an integer numeric value.

Item Description
Syntax `value.is_num_int()`
Arguments none
Returns boolean-style number

Example:

(10).is_num_int();    // true
(10.5).is_num_int();  // false

is_string()

Checks whether the value is a string.

Item Description
Syntax `value.is_string()`
Arguments none
Returns boolean-style number

Example:

'abc'.is_string();    // true
123.is_string();      // use (123).is_string() in real code

When calling a method on a numeric literal, use parentheses:

(123).is_string();    // false

is_bool()

Checks whether the value can be interpreted as a boolean value.

Item Description
Syntax `value.is_bool()`
Arguments none
Returns boolean-style number

Finite numbers are boolean-compatible. Strings `true`, `false`, `1`, and `0` are also boolean-compatible.

Example:

(1).is_bool();        // true
'false'.is_bool();    // true
'abc'.is_bool();      // false

Previous: Built-in methods

Next: Number Methods

exprv4/reference/methods/common_value_methods.txt · Last modified: by 127.0.0.1

Page Tools