sb logoToday I Learned

Camel Case or Snake Case?

I recently had a need to convert to snake case string. I remember Rails had the ActiveSupport Inflector class that made this easy, but I couldn’t remember ever seeing this in Elixir (Outside of the library Inflex.) That’s when I discovered some string helpers in the Macro module.

iex> Macro.camelize( "internal_representation_value")
"InternalRepresentationValue"

iex> Macro.underscore("InternalRepresentationValue")
"internal_representation_value"