Avatar
norio_nomura 5/23/2017 8:46 AM
struct Countdown: Sequence, IteratorProtocol { var count: Int mutating func next() -> Int? { if count == 0 { return nil } else { defer { count -= 1 } return count } } } let s = Countdown(count: 10).prefix(3) // AnySequence<Int>