In my case I have string with coma.
var stringWithComa = "1,2"
When I try to convert it to Float or Double I receive nil as expected.
Float(stringWithComa)//nil
Double(stringWithComa)//nil
But when I do Decimal(string: stringWithComa) I receive 1.
Why this issue is happening ?
Decimal(string:)just stops parsing as soon as an invalid character is found.Decimal(string: "1.23💣")returns1.23without exploding.Decimal(string: stringWithComma, locale: .current)