If you’re wanting to play around with Elixir in a REPL you can use iex.
Note: To exit iex just CTRL+C twice.
Within the shell we can simply type in code on a line and press enter to evaluate it. So for example type
le = [1,10,20]
press enter and the shell will display the list now bound to the value l.
Now type
length(l)
and the shell should display 3, the length of the list.
To get help from the shell, execute
h()
Compiling a module into iex
Whilst you’re developing your modules you might which to test them via the shell, in which case from you can load it when you start iex using (in this case my module in called math.ex)
iex math.ex
or if you’ve already started iex, simple use
c "math.ex"
The line above compiles your code and loads into iex so it’s now available to call from the shell.
If you want to view the exports on a module (in this example on my Math module), use the command
exports(Math)