string data type is not a class?
1 view (last 30 days)
Show older comments
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 Comment
Rik
on 14 Jul 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.
Accepted Answer
Rik
on 14 Jul 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 Comments
Steven Lord
on 15 Jul 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
on 15 Jul 2021
It makes sense to solve the ambiguity this way, but I still think it would merit a remark in the doc.
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!