ismethod(string('test'), 'endsWith') under R2016b and 2018b
1 次查看(过去 30 天)
显示 更早的评论
R2016b:
ismethod(string('asd'), 'endsWith')
ans = logical(1)
R2018b:
ismethod(string('asd'), 'endsWith')
ans = logical(0)
Is this documented? I did not finf in in the release notes.
Actually ismethod uses the class of the first input. But for string there seems to be an exception. Is this the correct usage:
data = string('asd')
ismethod(class(data), 'endsWith')
?
0 个评论
采纳的回答
Walter Roberson
2019-2-9
ismethod() calls upon methods(). methods() has two forms: it can be passed a class name, or an object. string('asd') is the same as "asd" and in all current versions, you can specify class names either as character vectors or as scalar string objects.
In R2016b when string objects had just been introduced, there were a lot of routines that had not been upgraded to accept string objects in place of character vectors or cell array of character vectors. Each release after that converted more and more routines. Most of them had been converted by R2018a, but R2018b release notes indicates changes continued even into R2018b, especially an new weird change to table(), timetable() and addVars() that is likely to lead to confusion.
3 个评论
Walter Roberson
2019-2-20
It is not documented that ismethod accepts the name of a class as the first argument. You should file a documentation complaint.
更多回答(1 个)
Jan
2019-3-22
1 个评论
Julian
2020-3-6
I just hit this problem - and derived the same workaround! I should have checked Answers first ... I searched only in bug reports for ismethod but there was nothing. The current flawed implementation is a bug because it contradicts the doc.
The future behaviour described in release notes of R2019a will correct the bug, although not yet there in R2019b. Avoid calling ismethod until it gets fixed!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Class Introspection and Metadata 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!