Discard elements of function output?

In MATLAB, I would write [~, two] = function_with_two_outputs() to discard the first of two function outputs. Is there a syntax for doing the same in Julia? That is, discard one or more elements of the tuple returned by a function?

I guess that an alternative would be to do two = function_with_two_outputs()[2]. Or is that a bad idea for some deep (or for that matter shallow) reason?

Not super discoverable I admit, but this discussion was had before here:

If you go through this thread you’ll see most of it is about whether (and how) this is possible in Julia.

1 Like

In Julia you’d just write _, two = function_with_two_outputs() (_ cannot be read from again). nargout shenanigans aren’t easily possible though.

2 Likes