Why does tab completion not work for certain subclass methods?
Mostra commenti meno recenti
I am trying to use tab completion with methods of a subclass, but it is not showing tab completion results for these methods.
I have defined a class, "ClassA" in MATLAB. This class has a method "printX" and property, "x":
classdef ClassA
properties
x
end
methods
%% Constructor
function obj = ClassA(x)
obj.x = x;
end
%% Helper Function
function printX(obj)
arguments
obj ClassA
end
disp(obj.x)
end
end
end
I also defined a class "ClassB" that inherits from "ClassA":
classdef ClassB < ClassA
methods
function obj = ClassB(x)
% Create the object
obj = obj@ClassA(x);
end
function Print(obj)
arguments
obj ClassA
end
% Print the object property
obj.printX();
end
end
end
I used argument validation blocks in the subclass method, "Print", to validate the object, "obj", as an instance of the superclass.
While methods defined in the superclass show up with tab completion, the methods defined in the subclass do not show up in the MATLAB Command Window or MATLAB Editor. However, they appear in the output list when using the "methods" function, and they work correctly when typing the method without tab completion.
After creating an instance "MyInstance" of the subclass, tab completion does not show the "Print" method when typing "MyInstance. + <TAB>".
Why does tab completion not work for certain subclass methods?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Class Introspection and Metadata in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!