String.to_integer("+") returns 0 is expected behaviour?

57 views
Skip to first unread message

-E:), niku

unread,
Jul 30, 2015, 12:00:27 PM7/30/15
to elixir-l...@googlegroups.com
Hi, folks.

I'm faced with following iex.
String.to_integer("+") and String.to_integer("-") return 0.
Is it a expected behaviour?

/Users/niku% iex
Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:4:4]
[async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Interactive Elixir (1.0.5) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> String.to_integer("42")
42
iex(2)> String.to_integer("a")
** (ArgumentError) argument error
:erlang.binary_to_integer("a")
iex(2)> String.to_integer(" ")
** (ArgumentError) argument error
:erlang.binary_to_integer(" ")
iex(2)> String.to_integer("+")
0
iex(3)> String.to_integer("-")
0
iex(4)> String.to_integer("*")
** (ArgumentError) argument error
:erlang.binary_to_integer("*")
iex(5)> String.to_float("+")
** (ArgumentError) argument error
:erlang.binary_to_float("+")

regards.

José Valim

unread,
Jul 30, 2015, 12:02:42 PM7/30/15
to elixir-l...@googlegroups.com
It is a bug, please file a bug report!



José Valim
Skype: jv.ptec
Founder and Director of R&D


--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CAFrD6Ztv%3DrCGdcu%3DS%2ByrhMGMvm%2BuEUebXv609M0bPzb7b%3DCtDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

ni...@niku.name

unread,
Jul 30, 2015, 12:21:59 PM7/30/15
to elixir-lang-talk, jose....@plataformatec.com.br
OK.

I created an issue.
https://github.com/elixir-lang/elixir/issues/3538

Thanks for your quick response!
Reply all
Reply to author
Forward
0 new messages