# Save variable to variable name

**URL:** <https://discourse.julialang.org/t/save-variable-to-variable-name/24565>\
**Category:** General Usage\
**Tags:** question, metaprogramming\
**Created:** [May 24, 2019, 12:53pm UTC](https://discourse.julialang.org/t/save-variable-to-variable-name/24565 "2019-05-24T12:53:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [May 24, 2019, 12:53pm UTC](https://discourse.julialang.org/t/save-variable-to-variable-name/24565/1 "2019-05-24T12:53:08Z")

</div>

Giving up…  
I have a bunch of JulaiDB tables and I want to save them. To avoid zipping through a list of their variables _and_ an irritatingly similar list of the variables’ names, I’d like to solve this with metaprogramming.

So instead of this:

```julia
for (variable, name) in zip((table1, table2, table3), ("table1", "table2", "table3"))
    save(variable, joinpath(repo, "$name.jldb"))
end

```

it would look something like this (but this doesn’t work):

```julia
for s in (:table1, :table2, :table3)
    @eval save($s, joinpath(repo, "$s.jldb"))
end

```

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [May 24, 2019, 1:15pm UTC](https://discourse.julialang.org/t/save-variable-to-variable-name/24565/2 "2019-05-24T13:15:28Z")

</div>

This should work:

```julia
@eval save($s, joinpath(repo, $("$s.jldb")))

```

You need to rounds of `$`: one for interpolating the symbol into the expression; another to interpolate the symbol name into the string (exactly like you’d have to without metaprogramming)
