I encountered the following Ruby code:
class MyClass attr_accessor :items ... def each @items.each{|item| yield item} end ...end
What does the each
method do? In particular, I don't understand what yield
does.
I encountered the following Ruby code:
class MyClass attr_accessor :items ... def each @items.each{|item| yield item} end ...end
What does the each
method do? In particular, I don't understand what yield
does.