Skip to content

Give a hint on how to remove array's element while iterating over it #12305

Description

@GofusProject

Your Godot version:
Godot 4.6

Issue description:
Class: Array

I was searching how to iterate through an array to remove/erase some of its elements. When I first read the docs, I understood that erasing while iterating on an array is not possible at all. The first comment of this reddit post advises to loop backward and to use remove_at. I think it would be nice to indicate in the docs that is possible to remove element this way, eventually directly providing a code snippet.

URL to the documentation page (if already existing):
https://docs.godotengine.org/en/4.6/classes/class_array.html#class-array-method-erase

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:class referenceIssues and PRs about the class reference, which should be addressed on the Godot engine repositorydiscussionenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions