Function: Empty
Function: Empty

Function: Empty

Empty ( VALUE )

Returns if a value is considered "empty."

Parameters

Parameter Type Description
VALUE VALUE The input value (any type).

Returns

VALUE(BOOLEAN) TRUE if empty, FALSE if not.

What It Does

This function returns if the provided value is considered "empty" - TRUE if so, FALSE if not.

  • If the value is boolean, an empty value is FALSE.
  • If the value is an integer, an empty value is 0.
  • If the value is floating-point, an empty value is 0.0 or NaN.
  • If the value is a string, an empty value is a zero-length string or a zero-length string after the whitespace is trimmed.
  • If the value is a list, an empty value is if it is length 0.

Example

Empty Example


world
{
	start()
	{
		textln("empty(true) = "+empty(true));
		textln("empty(false) = "+empty(false));
		textln("empty(0) = "+empty(0));
		textln("empty(10) = "+empty(10));
		textln("empty(0.0) = "+empty(0.0));
		textln("empty(NaN) = "+empty(NaN));
		textln("empty(Infinity) = "+empty(Infinity));
		textln("empty(\"\") = "+empty(""));
		textln("empty(\"      \") = "+empty("       "));
		textln("empty(\"apple\") = "+empty("apple"));
		
		local a;
		a = [1, 2, 3, 4, 5];
		textln("empty("+a+") = "+empty(a));
		a = [];
		textln("empty("+a+") = "+empty(a));
		a = [[], [], [], []];
		textln("empty("+a+") = "+empty(a));
		quit;
	}
}

Example Result Table

Value Result
BOOLEAN[false] > EMPTY > BOOLEAN[true]
BOOLEAN[true] > EMPTY > BOOLEAN[false]
FLOAT[Infinity] > EMPTY > BOOLEAN[false]
FLOAT[-Infinity] > EMPTY > BOOLEAN[false]
FLOAT[NaN] > EMPTY > BOOLEAN[true]
INTEGER[0] > EMPTY > BOOLEAN[true]
FLOAT[0.0] > EMPTY > BOOLEAN[true]
INTEGER[10] > EMPTY > BOOLEAN[false]
INTEGER[3] > EMPTY > BOOLEAN[false]
FLOAT[10.0] > EMPTY > BOOLEAN[false]
FLOAT[3.0] > EMPTY > BOOLEAN[false]
FLOAT[10.5] > EMPTY > BOOLEAN[false]
FLOAT[3.5] > EMPTY > BOOLEAN[false]
INTEGER[-10] > EMPTY > BOOLEAN[false]
INTEGER[-3] > EMPTY > BOOLEAN[false]
FLOAT[-10.0] > EMPTY > BOOLEAN[false]
FLOAT[-3.0] > EMPTY > BOOLEAN[false]
FLOAT[-10.5] > EMPTY > BOOLEAN[false]
FLOAT[-3.5] > EMPTY > BOOLEAN[false]
STRING[] > EMPTY > BOOLEAN[true]
STRING[ ] > EMPTY > BOOLEAN[true]
STRING[0] > EMPTY > BOOLEAN[false]
STRING[0.0] > EMPTY > BOOLEAN[false]
STRING[10] > EMPTY > BOOLEAN[false]
STRING[3] > EMPTY > BOOLEAN[false]
STRING[10.0] > EMPTY > BOOLEAN[false]
STRING[3.0] > EMPTY > BOOLEAN[false]
STRING[10.5] > EMPTY > BOOLEAN[false]
STRING[3.5] > EMPTY > BOOLEAN[false]
STRING[-10] > EMPTY > BOOLEAN[false]
STRING[-3] > EMPTY > BOOLEAN[false]
STRING[-10.0] > EMPTY > BOOLEAN[false]
STRING[-3.0] > EMPTY > BOOLEAN[false]
STRING[-10.5] > EMPTY > BOOLEAN[false]
STRING[-3.5] > EMPTY > BOOLEAN[false]
STRING[apple] > EMPTY > BOOLEAN[false]
STRING[banana] > EMPTY > BOOLEAN[false]
STRING[NaN] > EMPTY > BOOLEAN[false]
STRING[infinity] > EMPTY > BOOLEAN[false]
LIST[[]] > EMPTY > BOOLEAN[true]
LIST[[BOOLEAN[true], INTEGER[3], FLOAT[5.0], STRING[orange]]] > EMPTY > BOOLEAN[false]
×

Modal Header