They are different. Using examples from RDoc:
class Foo include Enumerable def each yield 1 yield 1, 2 yield end end Foo.new.each_entry{|o| po} # => 1 [1, 2] nil Foo.new.each{|o| po} # => 1 1 nil Foo.new.each{|*o| po} # => [1] [1, 2] []
The difference is that each_entry passes all the elements of a single block variable, behaving differently depending on the number of elements passed in one iteration: if not, it takes it as nil , if it is required, a parameter, otherwise it puts them in an array. each , on the other hand, passes to a single block variable only the first object that is passed at each iteration.
source share