From: Klaus Stein Date: 2010-11-04T17:45:14+09:00 Subject: Re: the dark side of inherited methods Intransition wrote: > > Mixins are just another way to do inheritance. It has the same issues. > The only difference is the module level --and that's just an arbitrary > deviation often circumvented by "ClassMethods" hacks.. > What I would like to have are Mixins (especially Enumerable) behaving some more clever. Asume I have some MyCollection class. I implement #each and include Enumerable. Now I can do: mc = MyCollection.new('some', 'data', 'here', 'and', 'there') mc4 = mc.select { |s| s.length != 4 } But, unfortunately, mc4.class is Array and not MyCollection. I have to implement select, reject and others by myself, loosing some of the nice help Enumerable gives me. I often want to chain things and call some mapping method on some collection class without falling back to Array. This could be solved if Enumerable looks for some MyCollection.newEnum() class method and calls it if present to create a new object for collecting the results of the select (or some other mechanism, not sure how to go best. Any way to tell Enumerable how to collect the results of the mapping method in a new MyCollection object will do). Klaus -- http://lapiz.istik.de/ The Answer is 42. And I am the Answer. Now I am looking for the Question.