On 8/6/07, Ronald Fischer <ronald.fischer / venyon.com> 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?

In addition to what others have said (especially David Black), they
throw different errors.

>> def foo
>>   yield
>> end
=> nil
>> foo
LocalJumpError: no block given
        from (irb):2:in `foo'
        from (irb):4
>> def bar(&block)
>>   block.call
>> end
=> nil
>> bar
NoMethodError: undefined method `call' for nil:NilClass
        from (irb):6:in `bar'
        from (irb):8

I also consider yield() to be more idiomatic unless you need to
manipulate or pass along the proc object to another method.