Kernel.apply/3 keeps throwing this exception. I’m trying to dynamically run a module name + def from a map string field.
MathOperators.multiplier(event, inputs)
works however
Kernel.apply/3 keeps throwing this exception. I’m trying to dynamically run a module name + def from a map string field.
MathOperators.multiplier(event, inputs)
works however
Hi,
In Elixir, Module names are actually prefixed with “Elixir” – You can see this in IEx:
iex(18)> Atom.to_string(MyModule)
"Elixir.MyModule"
So, the error is technically correct – “MathOperators” as a module doesn’t exist, but “Elixir.MathOperators” does!
The Module concat/1 and concat/2 functions can help alleviate this problem for you:
https://hexdocs.pm/elixir/1.13.4/Module.html#concat/1
So, instead of, String.to_atom("MathOperators")
, try: Module.concat(["MathOperators"])
ahah that worked thank you good sir. I knew it was something easy and now I know