defmodule MyModule do
def print do
IO.puts "hi all"
end
end
This is my Elixir module contained in MyModule.erl
iex MyModule.erl
MyModule.print
I was trying to run the elixir method using a shell script. It compiles the file but
iex MyModule.erl
is not running. I think it's because the first command goes to Erlang virtual machine. How to call this method?
Elixir files generally have .ex extension. And if you are not planning to compile it, we recommend using the .exs file. We cover those differences in our getting started guide.
Assuming you write the file above to "mod.exs", one of the ways to achieve what you want is:
elixir -r mod.exs -e "MyModule.print"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments