metaclass
Returns the meta.class object that describes the class of an object.
Category: Programming > Classes
Syntax
mc = metaclass(obj)
Returns the class description of obj, which can be a built-in value or an object.
Description
metaclass is the programmatic form of the ?ClassName syntax: it gives access to the reflection data of a class. Use mc.Name for the class name, mc.SuperclassList for the direct superclasses, and the property and method lists to inspect what a class defines.
Because it takes an instance, metaclass(x) always describes class(x). To start from a class name only, create or pass an instance of that class.
Input arguments
obj- Any value. Its class is described, not the value itself.
Output arguments
mc- A
meta.classobject with properties such asName,SuperclassList,PropertyList,MethodListandHandleCompatible.
Example
Inspecting a built-in class
mc = metaclass(containers.Map);
disp(mc.Name)
disp({mc.SuperclassList.Name})
disp(mc.HandleCompatible)
Output
containers.Map
{'handle'}
1
Notes
For built-in classes the property and method lists contain the members MatLivre knows, so their lengths can differ from MATLAB's.