string data type is not a class?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Rik
2021-7-14
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.
采纳的回答
Rik
2021-7-14
help methods
This suggests that you can't use the methods(object) syntax for char and string inputs.
methods('1')
methods(class("1"))
7 个评论
Steven Lord
2021-7-15
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
2021-7-15
It makes sense to solve the ambiguity this way, but I still think it would merit a remark in the doc.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!