47
41

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Swift]多次元配列の宣言の仕方

Posted at

#多次元配列の宣言の仕方

誤った宣言

let matrix:String[][] = [["hoge","fuga"] ,["ohayo","hello"]]

「Array types are now written with the brackets around the element type」というエラーが出ます。

正しい宣言

let matrix:[[String]] = [["hoge","fuga"] ,["ohayo","hello"]]

println(matrix[0][1])//"fuga"

二重括弧の中に型名を入れると動くようです。

47
41
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
47
41

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?