Famous author C.S. Lewis, who penned Chronicles of Narnia, on how to keep yourself away from heartbreaks:
There is no safe investment.
To love at all is to be vulnerable.
Love anything, and your heart will certainly be wrung and possibly broken.
If you want to make sure of keeping it intact, you must give your heart to no one, not even to an animal.
Wrap it carefully round with hobbies and little luxuries; avoid all entanglements; lock it up safe in the casket or coffin of your selfishness.
But in that casket—safe, dark, motionless, airless—it will change.
It will not be broken; it will become unbreakable, impenetrable, irredeemable.
The alternative to tragedy, or at least to the risk of tragedy, is damnation. The only place outside of Heaven where you can be perfectly safe from all the dangers and perturbations of love is Hell.
—C. S. Lewis, The Four Loves