-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use NSDecimalString(_:_) for Decimal -> String conversion. #2396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci test linux |
Foundation/Decimal.swift
Outdated
var decimalSeparator: String? | ||
if let locale = locale as? Locale { | ||
decimalSeparator = locale.decimalSeparator | ||
} else if let dictionary = locale as? Dictionary<NSLocale.Key, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be [NSLocale.Key: Any]
?
Note that unlike Darwin, NSLocale.Key
will not automatically bridge from String
or NSString
. Should we have a branch for that too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a branch for [String: String]
.
For the [NSLocale.Key: Any]
case wouldn't that then mean as!
casting the value to String
? It that what you want it changed to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the current patch is good as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(After adding the branch.)
- This allows using an optional Locale to localise the output. - Update Decimal.description, NSDecimalNumber.description and NSDecimalNumber.description(withLocale) to call NSDecimalString().
2bd89a9
to
4e41c33
Compare
@swift-ci test linux |
This allows using an optional Locale to localise the output.
Update Decimal.description, NSDecimalNumber.description and
NSDecimalNumber.description(withLocale) to call NSDecimalString().