LoginSignup
11
11

More than 5 years have passed since last update.

SwiftのArrayの書き方がちょっと変わった

Last updated at Posted at 2014-07-07

注:挙動も大きく変わってたので、別に記事を書きました
SwiftのArrayがヤバくなくなった

先ほどXcode6beta3を入れてswiftのプロジェクトを開いたところ、Warningが増えていた。

Array types are now written with the brackets around the element type

これまでの配列の型の指定の書き方が、非推奨になって新しい書き方に変わるらしい。
エラーではないので、どちらでも動作上は問題ありません。

Arrayの型指定
//Xcode6beta2以前
let arrayOld : Int[] = [10, 20, 30]

//Xcode6beta3以降
let arrayNew : [Int] = [10, 20, 30]

こんな感じで、型の後ろに[]ではなくて、[型]と囲むようになりました。
新しい書き方のほうが直感的でいいですね。

11
11
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
11
11