ismethod(string('test'), 'endsWith') under R2016b and 2018b
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jan
am 9 Feb. 2019
Kommentiert: Julian
am 6 Mär. 2020
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Feb. 2019
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 Kommentare
Walter Roberson
am 20 Feb. 2019
It is not documented that ismethod accepts the name of a class as the first argument. You should file a documentation complaint.
Weitere Antworten (1)
Jan
am 22 Mär. 2019
1 Kommentar
Julian
am 6 Mär. 2020
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!
Siehe auch
Kategorien
Mehr zu Class Introspection and Metadata finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!