# Best way to create/assign variables based on strings

**URL:** <https://discourse.julialang.org/t/best-way-to-create-assign-variables-based-on-strings/3001>\
**Category:** New to Julia\
**Created:** [April 1, 2017, 4:47pm UTC](https://discourse.julialang.org/t/best-way-to-create-assign-variables-based-on-strings/3001 "2017-04-01T16:47:43Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![NickNack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nicknack/32/1792_2.png) [@NickNack](https://discourse.julialang.org/u/NickNack)\
**Post date:** [April 2, 2017, 3:46pm UTC](https://discourse.julialang.org/t/best-way-to-create-assign-variables-based-on-strings/3001/10 "2017-04-02T15:46:25Z")

</div>

> [@yuyichao](#):
>
> If this is local scope, it’s impossible and won’t be possible. Use a `Dict` with `String` as keys to hold the value instead.

I agree that using a Dict is better in most cases. However, by defining a macro it is certainly not impossible to create variables in local scope only. I posted [one possible solution in another thread](https://discourse.julialang.org/t/string-as-a-variable-name/2195/7). Or did I misunderstand what you meant?

---

_[View the full topic](https://discourse.julialang.org/t/best-way-to-create-assign-variables-based-on-strings/3001)._
