From: Ian Leitch Date: 2007-08-06T20:29:09+09:00 Subject: Re: yield or call? ------=_Part_79117_33320132.1186399747564 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Watch out there, "yield b" isn't the same as "b.call", you're probably aware of this, but from your example one could get confused with your reuse of the variable 'b'. I believe the general consensus is that unless you need to do something special with the block, i.e foo.instance_eval(&block), then just use yield. It's certainly much cleaner to read than taking &block as a parameter all over the place just for the sake of using .call. On 06/08/07, Ronald Fischer wrote: > > def f(&b) > ... > b.call > ... > end > > def g > ... > yield b > ... > end > > As far I understood the documentation for call and yield, both are > equivalent: > > f { ... } > g { ... } > > Is there a principal reason when to prefer call over yield (or vice > versa), or are these only syntactic variations of the same feature? > > Ronald > -- > Ronald Fischer > Phone: +49-89-452133-162 > > ------=_Part_79117_33320132.1186399747564--