Today I Learned

hashrocket A Hashrocket project

Convert A String To An Integer

The erlang module has built-in functions for converting between types. To convert a string (list) to an integer, you can employ the list_to_integer/1 function:

> erlang:list_to_integer("55").
55

The function defaults to base 10, so if you are working with a different base, you can use the list_to_integer/2 version:

> erlang:list_to_integer("1000", 2).
8

See the erlang docs for more details.

See More #erlang TILs