613613# This type of objects can be created by Enumerable#chain and Enumerator#+.
614614#
615615class Enumerator::Chain [out Elem] < Enumerator[Elem, void ]
616- include Enumerable [Elem]
616+ # * `Rubocop: `self` type is not allowed in this context
617+ # * {Enumerator::Chain#each} without block doesn't return `self`, unlike {Enumerator#each}.
618+ #include Enumerator::_Each[Enum, self] # Workaround: def each:
619+
620+ # <!--
621+ # rdoc-file=enumerator.c
622+ # - Enumerator::Chain.new(*enums) -> enum
623+ # -->
624+ # Generates a new enumerator object that iterates over the elements of given
625+ # enumerable objects in sequence.
626+ #
627+ # e = Enumerator::Chain.new(1..3, [4, 5])
628+ # e.to_a #=> [1, 2, 3, 4, 5]
629+ # e.size #=> 5
630+ #
631+ def initialize : (*_Each[Elem] enums) -> void
617632
618633 # <!--
619634 # rdoc-file=enumerator.c
@@ -626,5 +641,10 @@ class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
626641 #
627642 # If no block is given, returns an enumerator.
628643 #
629- def each : () { (Elem) -> void } -> void
644+ def each : () { (Enum) -> void } -> self
645+ | () -> Enumerator[E, self ]
646+
647+ # wrong argument type chain (expected enumerator) (TypeError)
648+ def with_index : (?Integer) ?{ (?) -> untyped } -> bot
649+ def each_with_index : () ?{ (?) -> untyped } -> bot
630650end
0 commit comments