string data type is not a class?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would expect the following to pull up a list of methods for the string data type, but it does not:
methods("1")
Is there any rationale to this behavior?
1 commentaire
Rik
le 14 Juil 2021
s={string([])};cellfun('isempty',s),cellfun(@isempty,s)
This implies the isempty function is overloaded for strings (which is what the cellfun doc warns about for the legacy syntax), but this fact is not reflected in the values methods returns.
Why all these implementation details are hidden is a mystery to me.
Réponse acceptée
Rik
le 14 Juil 2021
help methods
This suggests that you can't use the methods(object) syntax for char and string inputs.
methods('1')
methods(class("1"))
7 commentaires
Steven Lord
le 15 Juil 2021
There are a couple entries in the Release Notes related to the interaction between string arrays and the ismethod function, but I don't see any about string arrays and the methods function. I could have overlooked one, though, since searching the Release Notes for the word "method" or "methods" finds a lot of hits.
Rik
le 15 Juil 2021
It makes sense to solve the ambiguity this way, but I still think it would merit a remark in the doc.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!