I have supervisor which spawns dynamic child using spawn_link. When I create new child:
create_my_child().
it return:
{ok, <0.324.0>}
so everything happy. I try to assign variable to child from console:
{ok,X} = create_my_child()
I get error saying:
exception error: no match of right hand side value
and says:
{supervisor,do_start_child_i,3
I done all difficult work, is possible to do this for child process?
If you’re doing all this in the console, then X is already bound to return Pid of the first
spawn_linkcall, and the subsequent attempt to match{ok, X}withcreate_my_child()call fails with the “no match of right hand side” error.In Erlang, variables are not mutable, so you cannot re-assign
Xafter it already has a value. In the console, you could dof()to the clear the shell’s variables, but the easier solution is to simply bind do a different variable (ieX2)