+12 works as "positive 12" in English, so why not in Elm? It's intuitive 
that `-12` means -12, so it follows that `+12` could well mean 12. This 
isn't unprecedented (Scala and Java).

Following this discussion (below) on Slack #beginners, I think that `+12` 
should be interpreted by Elm the same way as `12` is, rather than as `+ 
12`. I don't think many, if any, write `+12` to mean `+ 12`.

What do you think? Even if the use-case below isn't compelling enough to 
make the change, what use-case or what else would keep the change from 
being made?

Here's the discussion:

"In Elm, is there a reason why -12 is a valid number while +12 is not?... 
I was trying to parse the "+12" string to an int and getting parse 
errors... My use case is validating a form when I enter a number of 
decibels to change audio volumes. I wanted it to work with -10 or +12 or 
just 12."

"Just to be clear, I can find a work around my use case, it’s not big deal. 
I just found it surprising."

> String.toInt("+12")
Err "could not convert string '+12' to an Int" : Result.Result String

"The above is confusing, even Java gets it right :slightly_smiling_face:"

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to