Created
May 13, 2016 14:12
-
-
Save daveshah/97b227beb944d73f80d6e39969071d25 to your computer and use it in GitHub Desktop.
Parsing lolz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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