Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4623

What does the "yield" keyword do in Ruby?

$
0
0

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.


Viewing all articles
Browse latest Browse all 4623


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>