Adi bin Hatim reported,

A man came to him asking for a hundred dirhams, and he said, "You ask me for a hundred dirhams when I am the son of Hatim? By Allah, I will not give you anything!"Then he said, "Were it not that I heard the Messenger of Allah ﷺ say, 'Whoever swears an oath and then sees something better than it, let him do that which is better,' I would have refused."And he added, "You shall have four hundred from my stipend."

Muslim 4280

Sahih

حدثني محمد بن حاتم حدثنا بهز حدثنا شعبة حدثنا سماك بن حرب قال سمعت تميم بن طرفة قال سمعت عدي بن حاتم أن رجلا سأله فذكر مثله وزاد ولك أربعمائة في عطائي

مسلم 4280صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Oaths
Chapter
Recommendation for one who swore an oath then saw something better to do what is better and expiate for his oath
Numbering
Darussalam 4280
Muslim 4280