Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
D D
D D am 9 Mär. 2022
Bearbeitet: Matt J am 9 Mär. 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?

Akzeptierte Antwort

Matt J
Matt J am 9 Mär. 2022
Bearbeitet: Matt J am 9 Mär. 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

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by