edmz

View on GitHub

Unofficial Elixr Un-FAQ

I decided to create a document containing a list of all the small, irrelevant or stupid questions that I have while learning Elixir.

According to Jose Valim, this is by design. The access operation is linear, so you should avoid it if you can.

Suprisingly, there is currently no way to do it. This is a legacy issue with the erlang shell.

One way is to store it in process. Have a recursive function that stores it and feeds the new value to itself:

def loop(value)
  receive do
    # get or create a new copy the value here, then loop
    loop(new_value)
  end
end

You could use a list as arguments. Or you can dynamically create a function with:

:erlang.make_fun(mod, name, arity)

Add :logger to the application list, and then require it in the modules you will use it.

Erlang does have one, and it works for elixir too:

:etop.start()