Question:

I saw garbage outside a masjid, and after picking it up, I realized there is half a chocolate in it. Do I throw it out? I heard some of the Companions used to eat food they found.

Answer:

It is established that Abdullah Ibn Umar radiallahu anhu used to eat dates he found on the ground.

Shaikh Bin Baz answered a similar question about a cleaner placing food in the garbage. Shaikh Bin Baz rahimahullah said:
“It is obligatory upon him to preserve it for the poor to eat from, and if there is no poor to eat from, then it is obligatory upon him to place it in a place far away from trial so that animals can eat it. If that is not easy, then it is obligatory for him to leave it in the carton it is in or the case bag or the likes.”

[Reference]

~ Faisal Ibn Abdul Qaadir Ibn Hassan

————–

If it is from those public garbage places while it is still eatable, then he should give it to one of the animals who will eat it. If it is from one’s garbage or another Muslim brother’s garbage while it is still clean and eatable, then he should wipe the areas which were open by his hand or by any means, [and] then he can eat it if his stomach can bear it inshaa Allah and Allah knows best.

~ Abu Fajr AbdulFattaah bin Uthman