# Tuple destructuring / zip() on tuple of arrays

**URL:** <https://discourse.julialang.org/t/tuple-destructuring-zip-on-tuple-of-arrays/16414>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [October 16, 2018, 3:46pm UTC](https://discourse.julialang.org/t/tuple-destructuring-zip-on-tuple-of-arrays/16414 "2018-10-16T15:46:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgbarletta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pgbarletta/32/3204_2.png) [@pgbarletta](https://discourse.julialang.org/u/pgbarletta)\
**Post date:** [October 16, 2018, 3:47pm UTC](https://discourse.julialang.org/t/tuple-destructuring-zip-on-tuple-of-arrays/16414/1 "2018-10-16T15:47:00Z")

</div>

Hi!

Is it possible to make `zip()` work on a `Tuple` of `Array`s or to expand/destructure a `Tuple`?

I have a function returning a `Dictionary` but I would like it to instead return 2 arrays (keys & values) in case I don’t want a `Dictionary`:

```julia
function myfunc(...) 
...
   return array_1, array_2
end

```

And I would like something like this to work:

```julia
my_dict = Dict(zip(myfunc(...)))

```

or:

```julia
my_dict = Dict(zip(expand(myfunc(...))))

```

Is there something like `expand()`? I couldn’t find it in the Docs.  
Thanks!

---

<div class="post-metadata">

**Author:** ![yurivish](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yurivish/32/307_2.png) [@yurivish](https://discourse.julialang.org/u/yurivish)\
**Post date:** [October 16, 2018, 3:50pm UTC](https://discourse.julialang.org/t/tuple-destructuring-zip-on-tuple-of-arrays/16414/2 "2018-10-16T15:50:28Z")

</div>

You can say `Dict(zip(myfunc(x, y, z)...))` or `Dict(Pair.(myfunc(x, y, z)))`.

The `...` here is the [splat](https://docs.julialang.org/en/v1/manual/faq/index.html#...-splits-one-argument-into-many-different-arguments-in-function-calls-1) operator which will call `zip` with the individual elements of the tuple `(array_1, array_2)` returned from `myfunc`.

---

<div class="post-metadata">

**Author:** ![pgbarletta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pgbarletta/32/3204_2.png) [@pgbarletta](https://discourse.julialang.org/u/pgbarletta)\
**Post date:** [October 16, 2018, 3:52pm UTC](https://discourse.julialang.org/t/tuple-destructuring-zip-on-tuple-of-arrays/16414/3 "2018-10-16T15:52:32Z")

</div>

It works! Thanks for the speedy response!
