David A. Black wrote:
> Hi --
> 
> On Mon, 21 Nov 2005, 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
> 
> 
> Are you sure you've got Count as a method name?  It's possible, but 
> fairly bizarre.
Yeap, we're not talking Ruby objects here. It's an OLE API and it uses 
some pretty un-ruby names.
So col is an an OLE object missing such nice conveniences like each and 
collect and map.
Well, assumptions can kill you. The following works as is, so all this 
was a post with no reason to exist whatsoever.

class P
	attr_reader :c
	def initialize c
		@c=c
	end
	def to_s
		return @c
	end
end
def get_collection col,_class
	ar=Array.new
	col.each{|e|
		ar<<_class.new(e)
	}
	return ar
end

col=["w","o","w"]
ps=get_collection col,P
puts ps
 >
w
o
w

If only everything turned out so easy...
V.-
-- 
http://www.braveworld.net/riva

____________________________________________________________________
http://www.freemail.gr - δωρεάν υπηρεσία ηλεκτρονικού ταχυδρομείου.
http://www.freemail.gr - free email service for the Greek-speaking.