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!