Can I find out if a class is an abstract class before trying to instantiate it?
Afficher commentaires plus anciens
Can i somehow say:
if isAbstract(className)
% do something
else
% do something else
end
Réponse acceptée
Plus de réponses (4)
Image Analyst
le 17 Juil 2012
0 votes
I don't think so. But you should know just by looking at the code, or just try it and see. Why would you ever not know what you're calling and have to use the test you you described? Worst case, you could wrap your method call in a try/catch to do what you want, but I would recommend knowing beforehand than doing that.
Sam
le 18 Juil 2012
0 votes
Daniel Shub
le 18 Juil 2012
0 votes
It might be quicker to try and create the object in a try-catch and deal with errors when they happen.
Catégories
En savoir plus sur Whos dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!