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!