From: Damphyr Date: 2005-11-21T05:08:36+09:00 Subject: Re: Passing the class as an argument Damphyr wrote: > I'm too lazy to figure it out (and a bit hangover). > I have several collections of objects (read over an OLE API) that I > transform to arrays of ruby objects. > Against the DRY religion I ended up with several methods similar to the > following: > > def get_processors col > ar=Array.new > count=col.Count > 1.upto(count){|i| > ar< } > return ar > end > > Now, this begs for the working equivalent of > > def get_collection col, _class > ar=Array.new > count=col.Count > 1.upto(count){|i| > ar<<_class.new(col.GetAt(i)) > } > return ar > end > > How do I do it? > (I do know how do it - I think . It's just that the hangover is not > helping the search functions of my brain :) ) > > i.e. this would do what I want > def get_collection col, _class > ar=Array.new > count=col.Count > 1.upto(count){|i| > ar< } > return ar > end > > ...but, is there another way? And to clarify (it's just impossible to concentrate today :( ). Ideally I would like to call get_collection(ole_collection,Processor) which looks nicer than get_collection(ole_collection,"Processor") Cheers, V.- -- http://www.braveworld.net/riva ____________________________________________________________________ http://www.freemail.gr - ������ �������� ������������ ������������. http://www.freemail.gr - free email service for the Greek-speaking.