From: Thufir Date: 2007-11-18T05:02:12+09:00 Subject: Re: Composition: Build objects from other objects On Sat, 17 Nov 2007 22:40:20 +0900, Liam wrote: > v=Vehicle.new(Engine.new) > v.vroom > v.engine=MustangEngine.new > v.vroom > > > As far as comparison to Java, this example uses duck typing. As long as > it vrooms, you can use it as an engine for your vehicle. Hehe, fair enough. Ok, enough Java, it was just an entry point (although I would be interested to hear how this is addressed in other OOP oriented languages). What stands out about the above is: 1.) I don't follow all of the syntax, some of it's over my head (which is certainly ok). 2.) The engine is being instantiated *outside* of the class definition. I was assuming that the engine would be created in the vehicle's initialize method. The above technique is to specify the engine when the car is "manufactured" by passing a new instance of Engine into the new Vehicle instance. -Thufir