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

Which statement about `each_with_object` versus `reduce`/`inject` is correct?

r1 = [1, 2, 3].each_with_object([]) { |n, acc| acc << n * 2 } r2 = [1, 2, 3].reduce([]) { |acc, n| acc << n * 2 }