From cfb8ed6495c4c2eacf8689f436822b61b5a4c129 Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Wed, 8 Jan 2025 00:05:39 -0700 Subject: [PATCH] Add type for `Enumerator::Chain` --- core/enumerator.rbs | 24 ++++++++++++++++++++++-- test/stdlib/Enumerator_test.rb | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/core/enumerator.rbs b/core/enumerator.rbs index c87367155..c1f8ec394 100644 --- a/core/enumerator.rbs +++ b/core/enumerator.rbs @@ -613,7 +613,22 @@ end # This type of objects can be created by Enumerable#chain and Enumerator#+. # class Enumerator::Chain[out Elem] < Enumerator[Elem, void] - include Enumerable[Elem] + # * `Rubocop: `self` type is not allowed in this context + # * {Enumerator::Chain#each} without block doesn't return `self`, unlike {Enumerator#each}. + #include Enumerator::_Each[Enum, self] # Workaround: def each: + + # + # Generates a new enumerator object that iterates over the elements of given + # enumerable objects in sequence. + # + # e = Enumerator::Chain.new(1..3, [4, 5]) + # e.to_a #=> [1, 2, 3, 4, 5] + # e.size #=> 5 + # + def initialize: (*_Each[Elem] enums) -> void #