I am working with Swift's Decimal
type, trying to ensure that an user-entered String
is a valid Decimal
.
I have two String
values, each including a letter, within my Playground file. One of the values contains a letter at the start, while the other contains a letter at the end. I initialize a Decimal
using each value, and only one Decimal
initialization fails; the Decimal
initialized with the value that contains the letter at the beginning.
Why does the Decimal
initialized with a value that contains a letter at the end return a valid Decimal
? I expect nil
to be returned.
Attached is a screenshot from my Playground file.