How do I list all shell variables in iex?

I typed iex at the command line and now I am in the Elixir shell. I set x = "something", y = "something else" and so on. Then I go out for lunch and when I come back I want to see all the variable that are set in the shell. How can I do this?


1 Like

Curious, why would you want to do this? What pragmatic purpose does it serve?

1 Like

Let’s say that I was in the middle of a complex operation when I was interrupted and I want to resume my state and remind myself of where I am.

1 Like

binding() is what you are looking for. For example:

iex(1)> a = 1
iex(2)> b = 2
iex(3)> binding()
[a: 1, b: 2]

This works in the context of any elixir code.


Thanks - perfect. And because you are famous, I’m also honored :slight_smile:

1 Like