Next: , Previous: Documentation strings, Up: Syntax


3.1.6 Object type determination

The type of an object can be surmised in several ways:

3.1.6.1 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;
3.1.6.2 is/isof operators

The 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