The Messenger of Allah ﷺ came in to me and asked, "Do you have anything to eat?"We would say, "No."He would then say, "I am fasting."So he would continue his fast. Then later something would be given to us as a gift, and he would break his fast.She said, "Sometimes he would fast and then break it."I asked, "How is that?"She replied, "His example in this is like that of a man who goes out with charity. He gives some away and keeps some back."
حدثنا إسمعيل بن موسى حدثنا شريك عن طلحة بن يحيى عن مجاهد
دخل علي رسول الله ﷺ فقال هل عندكم شيء فنقول لا فيقول إني صائم فيقيم على صومه ثم يهدى لنا شيء فيفطر قالت وربما صام وأفطر قلت كيف ذا قالت إنما مثل هذا مثل الذي يخرج بصدقة فيعطي بعضا ويمسك بعضا
[Hasan]. Nasai reported it, 4/194, Book of Fasting, chapter "Intention in fasting, etc.", hadith 2325, from the hadith of Sharik with different wordings. He also reported it, hadith 2324, and elsewhere, via Abu Ahwas from Talha with similar wording. Its basis is found in Sahih Muslim, hadith 1154.