Multiple elixir commands on iex -S mix

The REPL executes elixir code, which generally means functions are called one per line. So you’d do:

iex(1)> IO.puts("hello world")
hello world
:ok
iex(2)> IO.puts("wazzup")
wazzup
:ok

You can put multiple commands on the same line and execute them unconditionally by separating them with a ;

iex(3)> IO.puts("hello world"); IO.puts("wazzup")
hello world
wazzup
:ok

You can use && to conditionally call functions as long as prior functions returned something “truthy”

iex(4)> true && IO.puts("wazzup")
wazzup
:ok
iex(5)> false && IO.puts("wazzup")
false

Basically it’s just Elixir code.

3 Likes