Menu

How to limit argument validation function visibility?

Reading 0:00
15s threshold

In Function.m I have

function Function(a)
arguments
a (1,1) double {Validator(a)}

end
printValue(a);
end

function Validator(a)
arguments

a (1,1) double
end
if mod(a,7)
error("Invalid argument.");

end

end

function printValue(a)
disp(a);
end

I want to further restrict the visibility of Validator such that it can be called only by Function. I tried to make Validator a nested function of Function, but MATLAB throws me the error "calling nested functions is not supported in arguments blocks". So how do I restrict Validator to be called only in Function and not in other local functions from Function.m (like printValue)?

Edit: sorry for formatting, but Reddit ignores spaces when I write code.

submitted by /u/Bofact
[link] [comments]