Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRubyEnumerable and custom eachSingle-choice MCQ

In a custom Enumerable, why is it good practice to start each with `return enum_for(:each) unless block_given?`?

def each return enum_for(:each) unless block_given? @items.each { |x| yield x } end