Skip to content

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

Merged
merged 1 commit into from
Jul 15, 2019

Conversation

spevans
Copy link
Contributor

@spevans spevans commented Jul 7, 2019

  • This allows using an optional Locale to localise the output.

  • Update Decimal.description, NSDecimalNumber.description and
    NSDecimalNumber.description(withLocale) to call NSDecimalString().

@spevans
Copy link
Contributor Author

spevans commented Jul 7, 2019

@swift-ci test linux

@spevans spevans requested a review from millenomi July 8, 2019 20:37
var decimalSeparator: String?
if let locale = locale as? Locale {
decimalSeparator = locale.decimalSeparator
} else if let dictionary = locale as? Dictionary<NSLocale.Key, String> {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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().
@spevans spevans force-pushed the pr_nsdecimal_string branch from 2bd89a9 to 4e41c33 Compare July 9, 2019 06:57
@spevans
Copy link
Contributor Author

spevans commented Jul 9, 2019

@swift-ci test linux

2 similar comments
@spevans
Copy link
Contributor Author

spevans commented Jul 9, 2019

@swift-ci test linux

@spevans
Copy link
Contributor Author

spevans commented Jul 10, 2019

@swift-ci test linux

@millenomi millenomi merged commit cee74f4 into swiftlang:master Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants