Does Elixir not support binary_to_existing_atom or list_to_existing_atom? I’ve always seen / used those functions for working with outside data. I’m also surprised that this article does not touch on records, when I played with Elixir I had to deal with them heavily.
Elixir has String.to_existing_atom/1, but it requires the user to catch ArgumentError in the case the atom does not already exist. I prefer exception handling to be reserved for truly exceptional situations, and anyway, it’s easier to use strings as keys.
I don’t mention records in the article by name, but technically, a keyword list is a list of two-element records. This post doesn’t deal with records in specific because it’s focused on key-value data structures.
Does Elixir not support
binary_to_existing_atomorlist_to_existing_atom? I’ve always seen / used those functions for working with outside data. I’m also surprised that this article does not touch on records, when I played with Elixir I had to deal with them heavily.Elixir has
String.to_existing_atom/1, but it requires the user to catch ArgumentError in the case the atom does not already exist. I prefer exception handling to be reserved for truly exceptional situations, and anyway, it’s easier to use strings as keys.I don’t mention records in the article by name, but technically, a keyword list is a list of two-element records. This post doesn’t deal with records in specific because it’s focused on key-value data structures.
Thanks for your comments!
Sure, those are in
:erlang: