Sahih Muslim Book 27, Hadith 25
This hadith is reported on the authority of Adi b. Hatim through another chain of transmitters.
When anyone amongst you takes an oath, but he finds (something) better than that he should expiate (the breaking of the oath), and do that which is better.
You asked me for one hundred dirhams and I am the son of Hatim; by Allah, I will not give you. But then he said: (I would have done that) if I had not heard Allah's Messenger (ﷺ) say: He who takes an oath, but then finds something better than that, should do that which is better.