I can't figure out how to view my current context in IEx. I want to see a list of all the variable that have been defined in the shell. Is this possible? Thanks.
Asked
Active
Viewed 1,091 times
2 Answers
15
You can get the current variables and their values with binding()
e.g.
iex(1)> a = 2
2
iex(2)> b = %{c: 3}
%{c: 3}
iex(3)> binding()
[a: 2, b: %{c: 3}]
See h binding
in IEx for more info.

semanticart
- 5,454
- 2
- 26
- 20
-
And something like `Enum.map(binding(), fn {k, _v} -> k end)` or `Keyword.keys(binding())` will get you just the variables names (as atoms). – Kenny Evitt Oct 16 '19 at 22:20