[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
    Comparing Classes
------------------------------------------------------------------------------

    Class objects can be used to compare classes, which can be used to
    check whether different objects belong to the same class.  For example:

        if obj1:class == obj2:class
            ? "obj1 and obj2 belong to the same class"
        else
            ? "obj1 and obj2 do not belong to the same class"
        endif

    This code uses the Class(y) predefined message class to obtain a
    reference to each object's class object, and compares the two
    references.

    A variation on this technique is to check whether an object belongs to
    a particular class.  An example of this is as follows:

        if obj:class == Window()

    This uses the class message to obtain a reference to the class object
    for the class to which obj belongs.  By comparing this to the reference
    to the class object returned by a class function such as Window()
    (assuming Window is a class), we can determine whether obj belongs to
    that class or not.

    Note that when comparing objects of any kind, the double-equal (==)
    operator must be used.  See Comparing Objects for more information.

See Also: Comparing Objects ■ class
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson