| Attention | Topic was automatically imported from the old Question2Answer platform. | |
| Asked By | Firty |
There is no invert in the array object anymore… How can I invert an array now?
| Attention | Topic was automatically imported from the old Question2Answer platform. | |
| Asked By | Firty |
There is no invert in the array object anymore… How can I invert an array now?
| Reply From: | jgodfrey |
Do you mean reverse()? There was (in 3.5) and still is (in 4.0) an Array.reverse().
I just asked the GPT chat lol, on Google I didn’t find anything about it, but that’s it, they changed it to reverse(). Thanks.
Firty | 2023-03-06 20:59
To be clear, it hasn’t been renamed. It was, and still is, reverse(). A classic case of ChatGPT confidently and happily providing incorrect information. ![]()
jgodfrey | 2023-03-06 21:09
Agreed, seen it all over Reddit and the problem, new programmers believe it’s a band-aid that cures all while in fact its just another tool to be used.
And tools only perform as well as the person using them.
Wakatta | 2023-03-07 02:59
You are not exactly correct. There is invert method in godot 3.x (Array — Godot Engine (3.6) documentation in English ), I actually had to rename it to reverse while migrating to 4.0
crazymeow | 2023-03-10 15:23
Hmmm… thanks @crazymeow. You are (obviously) correct. My memory seems faulty in this case. I vaguely remember verifying this in the docs before responding, but I was apparently looking at the wrong docs version… ![]()
jgodfrey | 2023-03-10 15:28
The AI comment is still valid because here we are a couple years later and google AI overview is still telling me about invert() instead of reverse(). Fortunately the editor complained and that made me dig a bit deeper and found this post. The AI tool is still useful as long as you expect it to lie to you ocationally.
LLMs are not people. They do not lie or hallucinate. The are autocomplete machines. If you expect it to always give you incorrect information about Godot, you will never be wrong. Even when it provides code that works, an LLM will always give you a complicated code-based solution rather than a good Godot node-based solution. And when your LLM code is complex enough, and it fails - it’ll be a bear to debug.