Today I Learned

A Hashrocket project

Elixir Maps With String/Colon Keys Become Atoms

While running the Elixir 1.6 formatter against Today I Learned, this change caught my eye. The formatter changes maps like this:

%{ "short_name": "TIL" }

To this:

%{ short_name: "TIL" }

This change makes sense because Elixir automatically coerces strings keys in a map, when followed by colons:

iex(1)> %{"foo": "bar"}
%{foo: "bar"}

And so, the conversion is implied. Elixir 1.6’s formatter forces us to be explicit and skip the conversion.

Looking for help? Elixir is quickly gaining momentum for web applications that need concurrency, performance, and the ability to connect to many different clients. The developers at Hashrocket are learning along with the rest of the development community that Elixir and Phoenix are viable Rails alternatives for the right application. Check out the source code for Today I Learned, written in Elixir, and contact us if you need help with your Elixir project.