Clear Filters
Clear Filters

How to acces the value of a Optional-Positional argument (~ argument) ?

2 views (last 30 days)
I want a function like this:
function foo(a, b, ~)
foo2(a, b, ~) % two ~ are same
end
However it's not allowed. So how to access the value of ~, or find another way to pass it to foo2?

Accepted Answer

Matt J
Matt J on 9 Mar 2022
Edited: Matt J on 9 Mar 2022
The ~ doesn't mean the input is optional. It means the function doesn't care what it is. Since your function does care, use a named argument.
function foo(a, b, c)
foo2(a, b, c)
end

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!