hit collider name (this)

hi, i’m new and i want to know if we can do something like that : if (hit.collider.name == this)
i want to put my code to different gameObjects but i don’t want to write different codes with different gameObjects names. Usually i do : if (hit.collider.name == “ball”)

thanks

Use hit.collider.gameObject == gameObject