inferiorto

Declares that a class has lower precedence than other classes.

Category: Other public functions: datatypes

Syntax

inferiorto('class1', 'class2', ...)

Marks the class being defined as inferior to the named classes.

Description

When an operation or function receives objects of two different classes, MATLAB decides whose method to call. If the class being defined is inferior to the other, the other class's method wins. inferiorto records that ranking and is called only from inside the constructor of a class.

It matters for classes that overload operators such as + and need a clear rule for mixed arguments. superiorto states the opposite ranking.

Input arguments

'class1', ...
Names of classes, as text.

Example

Outside a class method

try
    inferiorto('double')
catch err
    disp(err.message)
end
Output
Function 'INFERIORTO' can only be called from within a method.

The function only makes sense inside a class constructor, so a script gets an error.

Notes

This is the old-style class mechanism; in a script it always raises an error.

See also

superiorto class isa superiorfloat