On Sun, 2006-05-21 at 18:22 +0900, 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.

I guess it's probably the way it is because call isn't involved when a
method uses yield...?

l = lambda { |a| p a }
# => #<Proc:0xb7e9c0fc@(irb):1>

def l.call(*args); nil; end
# => nil

l.call(1)
# => nil

[1,2].each(&l)
1
2
# => [1, 2]

-- 
Ross Bamford - rosco / roscopeco.REMOVE.co.uk