Dependency injection is valuable in languages that lack inheritance and becomes more powerful in languages that have inheritance.
Without inheritance, dependency injection lets the container control constructor arguments. "Resolve for me an object of type
Carrotand use whatever constructor arguments you would like when creating that object."
With inheritance, dependency injection lets the container also control implementation. "Resolve for me an object of type
IVegetableand use whatever implementation and/or constructor arguments you would like."