This is always the case, so when you don’t chain a terminal operation, no intermediate operation will ever process any element.įinding out whether a terminal operation is short-circuiting, is rather easy. The term “lazy” only applies to intermediate operations and means that they only perform work when being requested by the terminal operation.
Having a short-circuiting operation in the pipeline is a necessary, but not sufficient, condition for the processing of an infinite stream to terminate normally in finite time. A terminal operation is short-circuiting if, when presented with infinite input, it may terminate in finite time. An intermediate operation is short-circuiting if, when presented with infinite input, it may produce a finite stream as a result. The actual term you’re asking for is short-circuitingįurther, some operations are deemed short-circuiting operations.