Get a property from a class

1 vue (au cours des 30 derniers jours)
Andrea Agostini
Andrea Agostini le 22 Juil 2019
Commenté : Andrea Agostini le 23 Juil 2019
Hello,
I have a class as per attached file "ktmDbiAccess.m".
I would like the property "fullFileName" is read ony; in my understanding I have to greate a get method to do that but I cannot understand how. I have found this example but it is not clear me yet how I have to modify the class and how should I call the "get" method in the caller script.
May you please provide an example? Or just modify my class.
regards,
Andrea

Réponse acceptée

Sean de Wolski
Sean de Wolski le 22 Juil 2019
You can set the SetAccess attribute of the properties block including it to make it read-only. No reason to deal with get(), actually, it would be set(), but still unnecessary.
properties (SetAccess = private)
fullFileName
end
  1 commentaire
Andrea Agostini
Andrea Agostini le 23 Juil 2019
thanks; it works

Connectez-vous pour commenter.

Plus de réponses (1)

Matt J
Matt J le 22 Juil 2019
Modifié(e) : Matt J le 22 Juil 2019
All you have to do is change the SetAccess property attribute, e.g.,
properties (SetAccess=private)
fullFileName
end
  1 commentaire
Andrea Agostini
Andrea Agostini le 23 Juil 2019
thanks; it works

Connectez-vous pour commenter.

Catégories

En savoir plus sur Software Development Tools dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by