Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRubylazy enumeratorsSingle-choice MCQ

Why does building an infinite pipeline with `lazy` and finishing with `first(3)` not hang, and how many times does the `map` block run?

calls = [] result = (1..Float::INFINITY).lazy .map { |x| calls << x; x * 2 } .first(3) p result p calls