Is it possible to know in what array an specific object is?

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

Hello. I have two arrays, A and B. I also have an object that could be in any of these arrays (A or B), I just need to know in what array my object is in, so if my object is in A, I should get A and so for B.
Is this possible? (Find the array that the object forms part of with just the object itself).

:bust_in_silhouette: Reply From: Lopy

Only with the object? No.
However, if you have the Arrays and the object, you can do:

if object in A:
    ...
elif object in B:
    ...

If you really need to get the Array from your object, and it is a real object (extending Object), you could use the “meta” functions to systematically set the Array it is in when moving it around.

If you are using those Array to distinguish between groups of objects, you might be able to use a single Dictionary instead.