-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Add String.reverse
method
#78529
Add String.reverse
method
#78529
Conversation
TL/DR: this is a hard problem and I don't think this implementation does it justice. |
I think the quirks of reversing should be documented as per the above mentioned |
@RedworkDE This is a good point, but note that some graphemes are composed of multiple code points: print("🇺🇦".length()) # 2 I think we can just document that the |
Something like: |
I don't know a reverse() implementation that does NOT break flags/emoji and the like. Should be documented and that's all. |
I believe that's a feature, Australia is upside down :o) @BastiaanOlij |
None of the other |
I agree that we shouldn't worry ourselves too much with how it handles complex unicode sequences and various composite languages. The resulting string won't be a valid word or sentence in practically any language. The application for this method lies somewhere else. Though the proposal doesn't elaborate why this is needed, only that it's needed. If we seriously want to discuss if this is worth it or not, the proposal must provide some details for a use case of reversing a string, and doing so especially efficiently too, to be considered for a built-in (cc @me2beats). But we may also just YOLO this, as the naive implementation is pretty straightforward. |
I used string reverse mainly for searching replacing and sorting also can be used in some algorithms for example for procedural generation of names |
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.
The implementation is straightforward, and it seems like a useful addition for the String class.
It's always hard to know what's the threshold for accepting new helper methods in core, but this seems OK to me, and nobody voiced any specific concerns in the past few weeks.
Thanks! |
Adds a simple method to return the copy of the string in reverse order. May be useful in some cases. Closes godotengine/godot-proposals#3503