It is documented.
> If successful, returns a tuple in the form of `{integer,
> remainder_of_binary}`.The spec could be improved to reflect this though On Mon, 8 Mar 2021 10:13:29 -0500 eksperimental <[email protected]> wrote: > It is not documented, > but it does not trim your string, what is does is to parse the first > integers it finds, and returns the remainder of the string as the > second element of the tuple. > > iex> Integer.parse("2ABC") > {2, "ABC"} > > > > On Mon, 8 Mar 2021 07:04:54 -0800 (PST) > Izzy Elwyn <[email protected]> wrote: > > > Hello, all! > > > > I recently had an issue with consistency in the behavior of > > Integer.parse/2 where it handles trailing whitespace, but fails to > > handle leading whitespace. > > > > Example: > > Integer.parse("12 ") > > {12, " "} > > Integer.parse(" 12") > > :error > > > > Because the trailing whitespace was handled, I had operated under > > the false assumption that the function would properly trim > > whitespace (both trailing *and* leading) and return a valid > > integer. For this reason, it look me a bit to track down leading > > whitespace as the root-cause of a production issue. > > > > I'd like to propose trimming whitespace as an enhancement to the > > functionality of Integer.parse/2 to improve consistency in its > > behavior. > > > > ~ Izzy > > > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/60463fb1.1c69fb81.334cc.b70aSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
