LoginSignup
6
6

More than 5 years have passed since last update.

SwiftでforでListを列挙するのにちょっと詰まった

Posted at

新しくアップデートされたXcode7で以下のコードを実行してみた

let colorList = ["bulew","yellow","red","green"]
for (index,value) in enumerate(colorList) {
    print((index,value))
}

ここで、エラーが出る。
'enumerate' is unavailable: call the 'enumerate()' method on the sequence

そこで、以下のようにしたらエラーが治って正常に実行できるようになった。英語では情報が出回っているのだが、日本語ではないので書いておいた

let colorList = ["bulew","yellow","red","green"]
for (index,value) in colorList.enumerate() {
    print((index,value))
}

ちょっとしたtipだが、役に立てていただければ幸いである。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6