godot-docs
godot-docs copied to clipboard
for (int i = 10; i > 0; i--) != for i in range(10, 0, -1)
Your Godot version: 3.4.4
Issue description: Misleading/inaccurate example of "backwards looping"
URL to the documentation page: https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_advanced.html#doc-gdscript-more-efficiently
Either the comment "range(b, n, s) # Will go from b to n-1, in steps of s." is wrong, or the example saying that for i in range(10, 0, -1) is equivalent to for (int i = 10; i > 0; i--) is wrong. I'm not sure what you want to do about this, esp. since even for i in range(10, 1, -1) would not be right, and for i in range(10, 2, -1) would probably cause confusion.
I think a better way to describe the range function is that the starting value is always inclusive and the ending value is always exclusive. I your point that the documentation describes it as a numerical comparison.
The two loops accomplish the same thing; I checked. This misleading documentation has been fixed in the engine, as shown in the attached image. The web API seems to not have been updated quite yet.

Indeed, description in class reference was improved lately, see: https://github.com/godotengine/godot/pull/60229. Note it's marked to be cherry-picked for 3.x so the same improved version should get into 3.5.
Also note that on-line docs aren't automatically updated (AFAIK it needs some manual work) so it might get some time until the changes will get on-line (on stable releases you can expect them to be updated though). That's why currently latest on-line docs still don't reflect these changes.
On the other hand, built-in class reference in the editor is always up-to-date (at the moment of the build).
But it seems like the mentioned tutotial needs its own fixes.