I encountered the following Ruby code:
class MyClass attr_accessor :items ... def each @items.each{|item| yield item} end ... end
yield tells ruby to call the block passed to the method, giving it its argument.
yield
yield will produce an error if the method wasn't called with a block where as return statement don't produces error.
return
return can only send single values where as Yield return object of huge values.
Yield