superclasses

Lists the superclasses of a class, from the nearest to the farthest.

Category: Programming > Classes

Syntax

superclasses(obj)

Displays the superclasses of the class of obj.

s = superclasses('ClassName')

Returns the names as a column cell array.

Description

superclasses follows the inheritance chain of a class. For a class declared as classdef B < A, where A itself derives from handle, it lists A and then handle. It answers a different question from isa, which tests one name; here you get the whole list.

A class that derives from nothing returns an empty list.

Input arguments

obj
An object, or the name of a class as text.

Output arguments

s
Cell array of class names, ordered from the direct superclass up to the root.

Example

Superclasses of a built-in class

s = superclasses(containers.Map)
Output
s = 1×1 cell

    {'handle'}

Notes

Called with no output argument, MatLivre prints a Superclasses for class ... block. Built-in value classes such as double are not accepted by name.

See also

metaclass methods properties isa class