From: Chris Hulan Date: 2008-07-07T21:31:23+09:00 Subject: Re: inheritance v passing object through the constructor On Jul 7, 7:37 am, aidy wrote: > Hi, > > Could anyone please tell me what the difference would be of inheriting > a class versus passing that class\object through the initialize > method? > > class ErrorBox < Box > > end > > v > > box ||= Box.new > > class ErrorBox > def initialize(box) > > end > > end > > And why would I do one over the other? > > Thanks > > Aidy Try googling "inheritance vs delegation" and "inheritance vs composition" Here is a discusin from Perl (http://www.perlmonks.org/index.pl? node_id=278375), looks to cover the area pretty good Artima has a lot of good info, here is an article on inheritence vs composition (similar to delegation), http://www.artima.com/designtechniques/compoinh.html cheers