He, meaning the Messenger of Allah ﷺ, said, "If you swear an oath and then see that something else is better than it, do the better thing and offer expiation for your oath."
أخبرنا عمرو بن علي قال حدثنا يحيى قال حدثنا ابن عون عن الحسن
قال يعني رسول الله ﷺ إذا حلفت على يمين فرأيت غيرها خيرا منها فأت الذي هو خير منها وكفر عن يمينك