Clarify the documentation of PoolVector3Array - clear PoolVector3Array

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jean dupond

Hello,

Is it possible to add somewhere in: https://docs.godotengine.org/uk/stable/classes/class_poolvector3array.html one example how to delete all elements from an PoolVector3Array?

It is confusing since 1. there is no .clear() method.
2. i tried to do it iterating over all indexes in the array and then removing each of them but that does not work if you isolate it in a function like

func _clearPoolVector3Array(pool: PoolVector3Array):
    for i in range(pool.size()):
        pool.remove(i)
  1. The only way i found is by using PoolVector3Array. resize(0). but that is not explicitly explained in docs.

I think this can be helpful for someone else in the future.

thanks!

:bust_in_silhouette: Reply From: zhyrin

Of course!
You can head over to the docs and check out how you can contribute to the documentation yourself. Contributing — Godot Engine (3.5) documentation in English
You can’t do it in a separate function since in 3.x they are passed as value: you would be modifiying a copy, not the original. This is explained in the docs: PoolVector3Array — Godot Engine (3.5) documentation in English.
Have you tried setting the array to a new empty array?