Is it possible that I execute two different commands when I use iex -S mix
like you can do un unix bash using the &&
operator?
Edit:
i.e.: I want to reload a module and test one of the module’s functions something like
r App.CoursesModule && App.CoursesModule.list_courses()
Hey @granyatee are you talking about running multiple mix tasks, or executing multiple commands inside the REPL that iex
provides?
1 Like
if you are talking the mix
command, you can achieve that with mix do
for example:
mix do task1, task2, task3
1 Like
Yeah, multiple commands inside the REPL
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
Just saw your edit, I’m pretty sure you want:
r(App.CoursesModule); App.CoursesModule.list_courses()
1 Like