I'm on iOS. So the behavior match Apple's NSScanner doc.
However, on non-Apple platform it works differently for locale == nil
, it uses the system default locale:
So to be portable across platforms, must specify en_US
for Decimal(string:locale)
so ".
" decimal separator is used always. I wonder: is the non-Apple version buggy since it doesn't match Apple's version base on eye balling at the source? If this is a bug, who should know about this?
Thanks for solving my mystery!