[ Swift ] enumerated()

Zion·2021년 2월 8일

Returns a sequence of pairs (n, x) where n represents a consecutive integer starting at zero and x represents an element of the sequence.

0부터 시작한 연속적인 정수값 n,
n번째 요소값을 나타내는 x,

이건 예시다

for (n, c) in "Swift".enumerated() {
	print("\(n): '\(c)'")
}
// Prints: 0: 'S'
// Prints: 1: 'w'
// Prints: 2: 'i'
// Prints: 3: 'f'
// Prints: 4: 't'
profile
어제보다만 나아지는

0개의 댓글