Unity GetComponent return value

Which game object of type Type is returned from the call


if the calling game object has more than one object of that type attached?

The documentation for this function only says a game object is returned if it exists, else null.

I have a game object with multiple Collider2Ds and want to know which one would be returned and if it’s consistent.

The first one in order from top to bottom in the inspector is the order in which they are returned I believe. If you do GetComponent then the top most component of that type is returned.
If you have a circle collider and box collider and or other different more specific types then do

GetComponent<BoxCollider2D> ()


Then loop through them.