How to destroy two gameobjects when they collide?

I have two gameobjects which both have rigidbody2ds and boxcollider2ds set as triggers. Both also have a script which implements the OnTriggerEnter2D method. Now I want to destroy both gameobjects when they collide, but I want to do it in their respective scripts. But for some reason when the collision happens only one of them gets the callback, and even that seems a bit random. The Destroy methods documentation says that the actual destruction happens only after the next Update, so that should affect the collision handling, but somehow it does.

How have you handled this situation?

This is happening because as soon as the first one is destroyed, it cant find the second one to destroy. Destroy the objects in the same script. Its better that way.

Destroy the other gameObject first then destroy the current gameObject

As thornekey says. But what you can do is either writing the code for destroying BOTH gameobjects in each trigger function or do a seperate script that handles all the destroying functions so it will not be destroyed when the gameobject gets destroyed.