+2 votes

Apologies if this has been answered, I did a search and did not find anything...

How come built-in types like PoolStringArray, PoolIntArray etc... do not have a has() method?

I find myself using those built-in types for memory optimization, but then having to create for loops to search if they have a value instead of simply using a has() function. It seems if those arrays are required to be composed of same types, there could be an optimized/fast way to search through the array (memory addresses) for a value.

Perhaps it has to do with one is passed by value vs. reference...

in Engine by (176 points)

1 Answer

+2 votes

As far as I know, the Pool* types are optimized for (unfragmented) memory usage. Therefore (AFAIK again) it will only be able to address continuous number ranges. Like a "traditional" Array.

If you require more array handling function then initialize an Array with such a Pool*Array and you wil have much more functionality like e.g. the .find() or has() methods.


If you build such an Array on your own anyway then you can start with an Array() right away... or a perhaps a dictionary is more suitable...depends on the use case.

by (3,298 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.