Next: Decisions, Previous: Documentation strings, Up: Syntax
The type of an object can be surmised in several ways:
object|type
is
/isof
operators
object|type
Every object contains a method called type
. This method returns the name of
the class as a string. This example will return System.string
as the output:
x = "string"; x|type|print;
is
/isof
operatorsThe other method is through the use of the is
/isof
operators. The difference
between the two is how far they search. is
only determines if the current instance is
of type x
, while isof
determines whether the current instance is of type
x
, or any child class of x
. Example:
import System.string; class x of System.string [ ]; ((make x) is x)|print; ((make x) is System.string)|print; ((make x) isof x)|print; ((make x) isof System.string)|print;
returns the following:
true false true true