NAME

@typeof - Determine the type of an object at runtime

SYNOPSIS

@typeof {INPUT}

DESCRIPTION

The @typeof directive is used to determine the type of a pointer at runtime.

The output of the @typeof directive will be either:

EXAMPLE

echo @typeof &@object
echo @typeof @pointer
echo @typeof "abc" # Blank line

if [[ @typeof &@object == "ExpectedClass" ]]; then
	# '@object' is an instance of 'ExpectedClass'
fi

NOTES

The input can be any rvalue at all, but should be a pointer to an object.

An easy mistake to make, for example, would be to pass an object directly instead of its address – this would implicitly call the object’s toPrimitive method, and attempt to find the “type of” that method’s output.