If you would believe the ancients, they had a whole theory of biogenesis, where flies were one of the things that spontaneously spawned from decaying organic matter. Apparently they’ve always did this, haha.
But, it honestly could be a mix of sources. They could be coming in from outside (they’re quite small and can fit through all kinds of small openings, cracks, and so on), or from some place the eggs were laid on: a drain (apparently this is popular for them), the trash, maybe the fruit themselves if they weren’t washed correctly. Etc.
The life cycle of the fruit fly from mating to hatching is really short–something like 48 hours, where eggs can take less than a day to hatch once laid, and the larva become adult flies in about a week or so. And, they are laid in the hundreds, all while being too small to really see.
Not the flies but the eggs are on the fruit you bring home. Imagine how small fruit fly *eggs* are.
They can’t just spontaneously generate when fruit appears. The store always has some, they lay eggs on the produce, you bring it home and the fruit is carrying eggs that hatch every day. Doesn’t help that they reproduce super fast so even if a couple hatch in your kitchen you soon have a bunch.
Latest Answers