Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
D D
D D le 9 Mar 2022
Modifié(e) : Matt J le 9 Mar 2022
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?

Réponse acceptée

Matt J
Matt J le 9 Mar 2022
Modifié(e) : Matt J le 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

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by