You need to pass your binding to eval quoted, see Kernel.binding/0. That
will return all variables up to some point. However, you will also see
binding is a keyword list, so you can simply get the variable value
directly from it.



*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

On Thu, Jul 14, 2016 at 5:31 PM, eksperimental <[email protected]>
wrote:

> Hello list:
>
> I'm trying to access variables via a list of atoms,
>
> So given:
> iex> a = 1
> ...> b = 2
> ...> c = 3
> ...> vars = [:a, :b, :c]
>
> I would like to print the value in each variable
> ...> for var <- vars, do: IO.inspect(var)
>
> How can I achieve this
>
> I have tried this to no avail
>
> iex> quote(do: var!(a)) |> Code.eval_quoted
> ** (CompileError) nofile:1: expected variable "a" to expand to an
> existing variable or be part of a match (elixir) expanding macro:
> Kernel.var!/1 nofile:1: (file)
>
>
> thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-talk/20160714223146.3fc22245.eksperimental%40autistici.org
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-talk/CAGnRm4KFQMRF5tb6hOz7YYoNiV%2B-MzNwwwRpeLK-snbhspgAtw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to