On 8/6/07, Phlip <phlip2005 / gmail.com> wrote:
> Ronald Fischer wrote:
>
> > Is there a principal reason when to prefer call over yield (or vice
> > versa), or are these only syntactic variations of the same feature?
>
> I am learning to consider 'yield' as a fossil of an early Ruby that could
> not treat the bound block as a variable. I only use 'yield' as a slight
> convenience - a few less characters to type - in application-specific code.
Do not do this, yield suffers a lot from a bad reputation it does not
deserve, see also David's benchmarks above.
>
> When writing API-style code, I always start with &block because it's only a
> matter of time before I refactor the code and start passing that &block into
> a helper method.
Why? I do not think that this is necessary.
Just replace the refactoring
old:  yield ==> something &blk + changing the def
with
new: yield ==> something &Proc.new

However I *never* use yield, but for a completely different reason, I
want my def to show if I yield or not.
In case I am unhappy with performance I can still change back.

Cheers
Robert



-- 
[...] as simple as possible, but no simpler.
-- Attributed to Albert Einstein