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

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

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…

:bust_in_silhouette: Reply From: wombatstampede

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.