# Output of functions

Dear users,
I have the following function:

``````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

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

must return only the value of x, but return

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

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

2 Likes
``````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])
5

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

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

``````

It was a type.

Ok!
I understood!
Thank you so much!

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.

3 Likes