func makeSequence() some Sequence<.Element = Int> { ... } var s = makeSequence() for item in s { print(item) } s = makeSequence() for item in s { print(item) }
(edited)makeSequence
の実体型を取得するのは理論上一回で済むですけど、func makeSequence() any Sequence<.Element = Int> { ... } var s = makeSequence() s = makeSequence()