-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
What is the sense of String.erase( int position, int chars )? #37918
Comments
Looks like this is the only String method that modifies the String instead of returning a new one 🤔 |
I'd vote for revising this method to make it immutable like other String methods. What should we rename it to? |
Yeah, this is confusing for me. It is better when all functionality works the same way. |
Maybe something like: splice? |
@MWFIAE Sounds good to me. The method would behave roughly like JavaScript's |
In Javascript, |
@theoway We already have |
Indeed, it'd be confusing. Then it'd be a good option to implement something like |
Why not just update erase to return the new string and not mutate the string as a backwards incompatible break for 4.0? Since going forward you'd need to do something with 'erase' anyway. It seems cleaner then cluttering the API up with another method name. |
Makes sense. But the method name needs to be changed, as it won't be erasing anymore(after changing the method) |
Upon thinking beyond the method itself, we have a similar method
Neither |
Indeed. If anyone has suggestions as to what it should be renamed to, drop 'em here. I'll make a PR to change the |
Maybe we should remove/unexpose |
That's a good idea. It can be replaced with a similar method, like splice(in Javascript), making sure that it doesn't mutate the string. How does that sound? |
@theoway Isn't JavaScript's |
Also, splice can add elements at the index from where old elements were removed. |
@theoway In this case, I guess it makes sense to implement an immutable version of |
Should I make the PR of implementation or make a proposal first? |
@theoway I think you can open a pull request directly against the |
@Calinou I had one more question. Since, we're implementing splice, it'll make |
@theoway I guess it makes sense to remove |
@Calinou Now there are many references to |
I am currently trying to test RichTextLabel nodes in 4.0 master because the new RTL got a whole bunch of features I really need in my project. My project is very heavy in dynamic text. Which means I need to format BBCode text of the RTL a lot, which in turn means I need to erase and insert (not necessarily replace) a lot of strings. Right now, I can't really do any of my testing because the latest master build appears to have erase() removed, but splice does not exist either. Also, just to note, erase is still featured in the online API documentation, however not in the build in API documentation. splice() is mentioned nowhere. The current master also gives me a showstopping error saying "this property does not exist". I would really love to test the new RTL BBCode features, but without being able to edit strings properly, there really is no point. It would be really nice if someone could reinstate erase() until we actually have splice() or any better solution. |
The Closing in favor of #43311, since we'll have to see whether we can actually expose a |
Godot version:
Any
OS/device including version:
Any
Issue description:
What is the sense of String.erase( int position, int chars ) if it does not return anything?
https://docs.godotengine.org/en/stable/classes/class_string.html#class-string-method-erase
The text was updated successfully, but these errors were encountered: