Skip to content

Commit 9169a40

Browse files
committed
choose_method: use which() for robustness
1 parent a5360f9 commit 9169a40

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

+stdlib/private/choose_method.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function fun = choose_method(method, name, minVersion)
22
arguments
3-
method (1,:) string
3+
method (1,:) string
44
name (1,1) string
55
minVersion {mustBeTextScalar} = ''
66
end
@@ -19,9 +19,12 @@
1919
end
2020

2121
if has()
22-
fun = str2func("stdlib." + m + "." + name);
23-
f = functions(fun);
24-
if ~isempty(f.file) || isfield(f, 'opaqueType')
22+
n = "stdlib." + m + "." + name;
23+
fun = str2func(n);
24+
% don't use functions() it's not for programmatic use and its behavior
25+
% changed in R2025a
26+
fp = which(n);
27+
if ~isempty(fp)
2528
return
2629
end
2730
end

0 commit comments

Comments
 (0)