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

Invert a string #12

Open
me2beats opened this issue Dec 19, 2021 · 0 comments
Open

Invert a string #12

me2beats opened this issue Dec 19, 2021 · 0 comments

Comments

@me2beats
Copy link
Owner

Tip-trick:

A method to invert a string:

static func invert_string(s:String)->String:
	var chars_pool = PoolStringArray()
	var length = s.length()
	chars_pool.resize(length)
	for i in length:
		chars_pool[i] = s[i]
	chars_pool.invert()
	return chars_pool.join("")

Additional context:
it works pretty fast compared to other gdscript options
I think implementing this method in core would be useful, see godotengine/godot-proposals#3503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant