I have the following module in my priv/ directory:
defmodule MyModule do
def hello(s) do
IO.puts s
end
hello("world")
end
when I mix run priv/funwithfuncs.exs:
** (CompileError) priv/funwithfuncs.exs:5: undefined function hello/1
How do I define a function in a seed/exs file??
NobbZ
3
When you try to call hello/1
it does not exist.
If you though call that function after that module has been fully created (thats with the end
that belongs to defmodule M do
) then it works:
$ cat foo.exs
defmodule M do
def hello(s), do: IO.puts(s)
end
M.hello "World"
$ elixir foo.exs
World
2 Likes