enumerated
-
[Swift] enumerated()Swift 2022. 2. 8. 01:58
Instance Method enumerated() (n, x) ์์ ์ํ์ค๋ฅผ ๋ฐํํ๋ค. ์ฌ๊ธฐ์ n์ 0์์ ์์ํ๋ ์ฐ์์ ์ธ ์ ์๋ฅผ ๋ํ๋ด๊ณ , x๋ ์ํ์ค์ ์์๋ฅผ ๋ํ๋ธ๋ค. Declaration func enumerated() -> EnumeratedSequence ใ ค Return Value ์ํ์ค๋ฅผ ์ด๊ฑฐํ๋ ์์ ์ํ์ค์ด๋ค. ใ ค Discussion ์๋ ์์ ๋ “Swift” ๋ฌธ์์ด์ ๋ฌธ์๋ฅผ ์ด๊ฑฐํ๊ณ , ๋ฌธ์์ด์์์ ๊ฐ ๋ฌธ์์ ์์น์ ๋ฌธ์๋ฅผ ํจ๊ป ์ถ๋ ฅํ๋ค. for (n, c) in "Swift".enumerated() { print("\\(n): '\\(c)'") } // Prints "0: 'S'" // Prints "1: 'w'" // Prints "2: ..