let stuffs = [ "APPLEPEN", "PINEAPPLEPEN", "PENPINEAPPLEAPPLEPEN"] var idx = 0 func next()-> String? { defer {idx += 1} guard idx < stuffs.count else { return nil } return stuffs[idx] } } let ppap = PPAP() for p in ppap { print(p) } /* APPLEPEN PINEAPPLEPEN PENPINEAPPLEAPPLEPEN */