enumerate

func enumerate<Seq : SequenceType>(_: Seq)

Return a lazy SequenceType containing pairs (n, x), where ns are consecutive Ints starting at zero, and xs are the elements of base:

> for (n, c) in enumerate("Swift") { println("\(n): '\(c)'" )}
0: 'S'
1: 'w'
2: 'i'
3: 'f'
4: 't'

Declaration

func enumerate<Seq : SequenceType>(base: Seq) -> EnumerateSequence<Seq>