# Discard elements of function output?

**URL:** <https://discourse.julialang.org/t/discard-elements-of-function-output/77179>\
**Category:** New to Julia\
**Tags:** tuple, functions\
**Created:** [February 28, 2022, 11:39am UTC](https://discourse.julialang.org/t/discard-elements-of-function-output/77179 "2022-02-28T11:39:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredrikpaues](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikpaues/32/34080_2.png) [@fredrikpaues](https://discourse.julialang.org/u/fredrikpaues)\
**Post date:** [February 28, 2022, 11:39am UTC](https://discourse.julialang.org/t/discard-elements-of-function-output/77179/1 "2022-02-28T11:39:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 28, 2022, 12:06pm UTC](https://discourse.julialang.org/t/discard-elements-of-function-output/77179/2 "2022-02-28T12:06:37Z")

</div>

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

> [@My wishlist for the next version of Julia](https://discourse.julialang.org/t/my-wishlist-for-the-next-version-of-julia/69987):
>
> As a Matlab person who recently switched over to Julia, below are some items on my wish list. Many thanks for your consideration! Creating a m x n sized NaN should be as simple as NaN(m, n). Right now, I have to do this: A = fill!(Array{Float64}(undef, m, n), NaN); If I have two 1-column data with the same size, A and B, I should be able to get an Index by Ind = A\>3 && B\<15. Right now, I would have to use map function to broadcast first: Ind = map(A, B) do a, b a\>3 && b\<15; end…

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

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [February 28, 2022, 12:11pm UTC](https://discourse.julialang.org/t/discard-elements-of-function-output/77179/3 "2022-02-28T12:11:09Z")

</div>

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