# Output of functions

**URL:** https://discourse.julialang.org/t/output-of-functions/30492
**Category:** New to Julia
**Created:** [October 30, 2019, 1:40pm UTC](https://discourse.julialang.org/t/output-of-functions/30492 "2019-10-30T13:40:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)
#### Post date: [October 30, 2019, 1:40pm UTC](https://discourse.julialang.org/t/output-of-functions/30492/1 "2019-10-30T13:40:35Z")

</div>

Dear users,  
I have the following function:

```julia
function Test(u,v,w)
    x = sum(v)
    y = prod(v)
    z = u .+ v 
    return (x,y,z)
end

```

But,if I want only the first, or only the second or only third output, how can I do it?  
For example, I my mind, the command

```julia
x = Test([1,2],[2,3],[3,4])

```

must return only the value of x, but return

```julia
(5,6,[3,5])

```

Anyone could help me please?

---

<div class="post-metadata">

### Author: ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)
#### Post date: [October 30, 2019, 1:43pm UTC](https://discourse.julialang.org/t/output-of-functions/30492/2 "2019-10-30T13:43:19Z")

</div>

`x, = Test([1,2],[2,3],[3,4])`  
Note the comma (after the `x`).

---

<div class="post-metadata">

### Author: ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)
#### Post date: [October 30, 2019, 1:49pm UTC](https://discourse.julialang.org/t/output-of-functions/30492/3 "2019-10-30T13:49:23Z")

</div>

> [@angeloaliano1](#):
>
> x = Test([1,2],[2,3],[3,4])

```julia
julia> function Test(u,v,w)
           x = sum(v)
           y = prod(v)
           z = u .+ v 
           return (x,y,z)
       end
Test (generic function with 1 method)

julia> x = Test([1,2],[2,3],[3,4])[1]
5

julia> y = Test([1,2],[2,3],[3,4])[2]
6

julia> z = Test([1,2],[2,3],[3,4])[3]
2-element Array{Int64,1}:
 3
 5

```

---

<div class="post-metadata">

### Author: ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)
#### Post date: [October 30, 2019, 1:50pm UTC](https://discourse.julialang.org/t/output-of-functions/30492/4 "2019-10-30T13:50:02Z")

</div>

It was a type.

---

<div class="post-metadata">

### Author: ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)
#### Post date: [October 30, 2019, 1:52pm UTC](https://discourse.julialang.org/t/output-of-functions/30492/5 "2019-10-30T13:52:17Z")

</div>

> [@angeloaliano1](#):
>
> x = Test([1,2],[2,3],[3,4])

Ok!  
I understood!  
Thank you so much!

---

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [October 30, 2019, 2:06pm UTC](https://discourse.julialang.org/t/output-of-functions/30492/6 "2019-10-30T14:06:22Z")

</div>

I actually didn’t know you could destructure like that. I sat here searching for like 30 seconds trying to figure out what comma you were talking about before I spotted it. For what it’s worth, even knowing that such destructuring is possible I find `x, _, _ = Test(...)` far more readable.
