Skip to content
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

[SR-7480] why can't I assign into a String indexed by range? #50023

Closed
mattneub opened this issue Apr 19, 2018 · 2 comments
Closed

[SR-7480] why can't I assign into a String indexed by range? #50023

mattneub opened this issue Apr 19, 2018 · 2 comments
Labels
improvement standard library Area: Standard library umbrella

Comments

@mattneub
Copy link

Previous ID SR-7480
Radar None
Original Reporter @mattneub
Type Improvement
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Improvement
Assignee None
Priority Medium

md5: 7e17cffb2443123995e2d50d13dd0fb6

Issue Description:

Is there some really good reason why I can't say (s and s2 are strings, r is a range on String.Index):

 s[r] = s2

Of course I know I can say

 s.replaceSubrange(r, with: s2)

But I feel I shouldn't have to.

@belkadan
Copy link
Contributor

Subscript assignment is supposed to be something that can be completed in time proportional to the size of the range being replaced. But that isn't generally true with a String, because even if two Strings are the same length (in terms of Characters) their stored representations might not match up.

@mattneub
Copy link
Author

Fascinating, thanks.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants