Testing the Type of an Object
<< previous | Chapter 7. Interactions Between Agents | next >>

## Testing the Type of an Object

If you need to determine whether an object is of a certain type, you can use the method is from Object.tz. The method takes a single keyword, "a", such that the method call can be written:

        item is a "Dog".

The call returns the int value 1 if the item is of the specified type, or 0 otherwise. This would most likely be part of an if statement:

        if (item is a "Dog"): item roll-over.

This method is useful in collision callbacks or when examining neighbors in order to determine the appropriate action.

<< previous | Up | next >>
Testing Whether an Object Responds to a Method Call | Table of Contents | Chapter 8. Physical Simulation