0 votes

My string s is "X1"

The string s is from the array cuttedstring (s = cuttedstring[0]), which was created by using the .split() function (cuttedstring = astring.split("_", true, 1)

If I try to erase the X:

var new_s = s.erase(0, 1)
print(new_s)

I get:

Null

But it should be

1

(as string)

What am I doing wrong?

Thanks!

Godot version 3.2.3
in Engine by (142 points)

1 Answer

+1 vote
Best answer

Weirdly enough, erase is the only String function that doesn't return anything. So instead the original string s is altered. Print the original string instead of new_s to get "1".

Edit: See https://github.com/godotengine/godot/issues/43311

by (7,190 points)
selected by

Thank you very much!

Now it works

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.