yolo007wizard

yolo007wizard

Kernel.apply/3 exception

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

Marked As Solved

JohnnyCurran

JohnnyCurran

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:

So, instead of, String.to_atom("MathOperators"), try: Module.concat(["MathOperators"]) :slight_smile:

Last Post!

yolo007wizard

yolo007wizard

ahah that worked thank you good sir. I knew it was something easy and now I know :stuck_out_tongue:

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement