Skip to content

Instantly share code, notes, and snippets.

@daveshah
Created May 13, 2016 14:12
Show Gist options
  • Save daveshah/97b227beb944d73f80d6e39969071d25 to your computer and use it in GitHub Desktop.
Save daveshah/97b227beb944d73f80d6e39969071d25 to your computer and use it in GitHub Desktop.
Parsing lolz
iex(11)> foo_int = "123foobar"
"123foobar"
iex(12)> String.to_integer(foo_int)
** (ArgumentError) argument error
:erlang.binary_to_integer("123foobar")
iex(12)> Integer.parse(foo_int)
{123, "foobar"}
iex(13)> :string.to_integer(foo_int)
{:error, :not_a_list}
iex(14)> :string.to_integer('123foobar')
{123, 'foobar'}
iex(15)> String.to_integer('123foobar')
** (ArgumentError) argument error
:erlang.binary_to_integer('123foobar')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment