1} **(CompileError) iex:11: illegal use of variable x in...">

Why don't you have a variable as a key in a map symbol?

For instance,

x = "foo" %{foo => 1} **(CompileError) iex:11: illegal use of variable x in map key 

Obviously, it builds a map at compile time, which might be more efficient, but why doesn't it return to the runtime constructor, like most languages ​​with data structure literals? It is interesting to know if there is something about the characteristics of the cards in Elixir that I miss.

Adding to the confusion in this post by Google Groups over a year ago, where Jose Valim says:

 Variable keys in maps will be available in the next Erlang release. 

But that was a year ago, now, and I cannot find any other references to this. What was the Erlang version for? I'm running 18 right now, and it's definitely still out of place.

+6
source share
1 answer

Erlang 18 has added support, and we need to upgrade Elixir to use this. Therefore, we plan to support it in the next version of Elixir, Elixir v1.2.

+14
source

All Articles