It’s funny, this throws an exception in REPL:
defmodule M1 do
def f_generic(a) do
:timer.sleep(a)
IO.puts "sleep #{a} done"
end
def run do
res = Enum.map([3000, 5000, 1000, 12000, 2000],
&(Task.async(fn x -> f_generic(&1) end)))
end
end
M1.run
Exception:
** (EXIT from #PID<0.84.0>) an exception was raised:
** (BadArityError) #Function<1.42455878/1 in M1.run/0> with arity 1 called with no arguments
:erlang.apply/2
(elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
(elixir) lib/task/supervised.ex:36: Task.Supervised.reply/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Ok, calling with an argument:
M1.run(123)
** (UndefinedFunctionError) function M1.run/1 is undefined or private. Did you mean one of:
* run/0
M1.run(123)