From: Robert Klemme Date: 2003-02-11T18:38:10+09:00 Subject: Re: inheriting from base classes "Phil Tomson" schrieb im Newsbeitrag news:b2a6o001rma@enews4.newsguy.com... > I'm much more likely to favor aggregation ('has-a') over inheritance > ('is-a') - as in the examples above. You can often use 'method_missing' > to redirect method calls to the contained object. I'd support has-a vs. is-a if is-a is not 100% clear. Composition with an Array is very much simplified by using Enumerable, so the effort to do the forwarding is very low, because it needs only an implementation of each like this: irb(main):109:0> class ArrayContainer irb(main):110:1> include Enumerable irb(main):111:1> irb(main):112:1* def initialize() irb(main):113:2> @arrayMember = [1,2,3] irb(main):114:2> end irb(main):115:1> irb(main):116:1* def each() irb(main):117:2> @arrayMember.each {|x| yield x} irb(main):118:2> end irb(main):119:1> end nil irb(main):120:0> irb(main):121:0* a = ArrayContainer.new # irb(main):122:0> a.to_a [1, 2, 3] irb(main):123:0> a.each { |x| p x } 1 2 3 [1, 2, 3] irb(main):124:0> Regards robert