Since nobody mentioned it, MATLAB also has the metaclass
function, which returns an object with various bits of information about the passed-in entity. These meta.class
objects can be useful for tests of inheritance (via common comparison operators).
For example:
>> metaclass(magic(1))
ans =
class with properties:
Name: 'double'
Description: ''
DetailedDescription: ''
Hidden: 0
Sealed: 0
Abstract: 0
Enumeration: 0
ConstructOnLoad: 0
HandleCompatible: 0
InferiorClasses: {0×1 cell}
ContainingPackage: [0×0 meta.package]
RestrictsSubclassing: 0
PropertyList: [0×1 meta.property]
MethodList: [272×1 meta.method]
EventList: [0×1 meta.event]
EnumerationMemberList: [0×1 meta.EnumeratedValue]
SuperclassList: [0×1 meta.class]
>> ?containers.Map <= ?handle
ans =
logical
1
We can see that class(someObj)
is equivalent to the Name
field of the result of metaclass(someObj)
.