On May 21, 2006, at 2:22 AM, Daniel Schierbeck wrote:
> Dave Burt wrote:
>> def to_proc
>>   proc {|*args| self.call(*args) }
>> end
>
> Yes, that works (thanks!), but I think it's against Ruby spirit to  
> require a certain class for a relatively high-level thing like  
> this. I can see why there's not really any way around a string  
> ultimately being a String object, through #to_str or #to_s, but all  
> that's really required by the return value of #to_proc is an object  
> that responds to #call.

#to_ary requires you to return an Array.

#to_str requires you to return a String.

In this spirit #to_proc requires you to return a Proc.

-- 
Eric Hodel - drbrain / segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com