If you have elixir code that dies with this message
17:39:25.661 [error] Error in process <0.60.0> with exit value: {undef,[{'Elixir.MyFunModule',fun_stuff,[],[]}]}
pid = spawn( MyFunModule, :fun_stuff, [] )
But runs just fine when you do this
pid = spawn( fn -> MyFunModule.funstuff([]) end )
The problem is the arity of the function you are using in the spawn/3 version.
Elixir uses the count of the elements in the third argument to spawn/3 to
find the function to spawn in the subprocess. In the first version it is looking
for a
MyFunModule.fun_stuff/0
which does not exist.
If you changepid = spawn( MyFunModule, :fun_stuff, [] )
to
pid = spawn( MyFunModule, :fun_stuff, [[]] )
it will then run without the process error above.
No comments:
Post a Comment