[mocha-developer] multiyield

Jay jay at jayfields.com
Mon Oct 9 15:53:49 EDT 2006

> No it's not in the framework already. Thanks for the patch. Am I  
> correct in thinking this patch only deals with simulating a method  
> that yields multiple times with a single parameter each time, like  
> this...
> def my_method
>   yield(1)
>   yield(2)
> end
   Yes, what I submitted only works for the above type scenario

> I'm wondering if we should also deal with the more generic case  
> where different numbers of parameters could be yielded each time,  
> like this...
> def my_method
>   yield(1)
>   yield(2,3)
> end
  You could handle this by passing in an array as an element of the  
array.  Then, in the yield you could yield and splat the value being  
> I like the way yields() currently mirrors the behaviour of returns 
> (), but it's becoming clear that yields() has to deal with more  
> multiplicity - you can only return once from a method with a single  
> value; whereas you can yield multiple values multiple times from a  
> single method. It would be good to deal with all this multiplicity  
> at once with a single simple syntax.
  Of course, I only made the change that fits what I need. :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mocha-developer/attachments/20061009/f771620a/attachment-0001.html 

More information about the mocha-developer mailing list